An enemy had grabbed a friendly NPC and was using him as a hostage and standing behind him as cover. The (new) DM seemed to be implying that the archers in our party would risk shooting the friendly.
I thought sacred flame would be good because it can target creatures in cover and seems to go through the environment without damaging anything else. So we reasoned that sacred flame would just fry the enemy and leave our friendly unharmed.
Would sacred flame potentially damage a creature other than the intended target? Or does it only affect the targeted creature?
No, sacred flame will not hurt the hostage
The description of sacred flame reads (PHB, p. 272; emphasis mine):
Flame-like radiance descends on a creature that you can see within range. The target must succeed on a Dexterity saving throw or take 1d8 radiant damage. The target gains no benefit from cover for this saving throw.
The spell hits the target, and cover has no effect on the spell. If a creature was using cover, and attacks were liable to hit that cover (as you said the ranged weapon attacks would be in this example), sacred flame would ignore the cover and would not potentially damage the cover.
This might be stylized as a bolt of holy fire arcing to strike from above, ignoring horizontal cover, but this stylization does not mean the attack would be blocked from cover above either.