When someone's shooting into melee, or even at a target right in line with an ally, I warn the player, "Be careful," or "There's a chance you might hit Ed." On a natural 1, I have the player roll a new attack. If that roll would hit the AC of the ally, THUNK.
I use the same method when a character with a long weapon, like a spear, is jabbing into a close hand-to-hand fight.
Odds of disaster are low, but it's enough to make people nervous. And it has come up. For low-level PCs, that friendly arrow can mean death.