Can weapons with Reach be used to attack “through” willing allies?

I’m picturing the Greek Phalanx formation, where soldiers were arranged in rows and the men in Row B or even Row C could attack the enemy by thrusting their spears between the soldiers in Row A.

Can you do that with a Reach weapon in DnD 5e? Attack an enemy even though there’s an ally (or even a row of allies) directly between you and them?