From what I understand, officers were spread out through the regimental line of battle to direct troops movement: the Colonel on the front left, the Lt. Col on the right, and the Major in the middle. The junior officers would be spread behind ranks of their respective companies, helping to dress the companies of the regiment.
The sergeants were positioned behind the lines of their platoons to assist their men in fighting and to encourage the men to continue to fight. The sergeants rarely stood in the line of battle. From their vantage point, the sergeants would be tasked with urging the men forward.
Are there any accounts of sergeants killing fleeing "cowards?"
It would seem to me that given the closeness of NCOs to their men, none would consciously shoot them in the back.
Edit:
Thinking more about this question, in the film Gods and Generals, I've never read the novel, Buster Kilrain says to Tom Chamberlain, "A sergeant doesn't fire his weapon until the men in front of him are killed, and then only if he wants to show off." I don't know the validity of this concept, but it would follow that a sergeant needs his weapon available at all times in case he needs to shoot a private or corporal in front of him.
Further though, it is a possibility given that a regiment is in two lines in a battle formation, a sergeant at the rear cannot effectively fire at the enemy. The sergeant, as seen in some Civil War films, can assist with broken weapons and move men around to fill gaps. Given that a squad at the time was 12 men (1 corporal, his privates, the corporal's sergeant and the sergeant's privates), there is actually quite a bit of micromanagement necessary. The corporals, according to Hardee's Field Manual I believe, would stand in front, with the junior enlisted standing between the corporals and the sergeants.
Just to clarify, presumably you're asking about the American Civil War?