Praise be to Allah.
The Sunnah is for the imam to stand in front of the worshippers, because this is what is proven in the Sunnah.
Ibn Abi ‘Umar (may Allah have mercy on him) said: The Sunnah is for the worshippers to stand behind the imam. If there are a number of worshippers, the Sunnah is for them to stand behind the imam, whether they are men or women, because the Prophet (blessings and peace of Allah be upon him) used to lead his companions in prayer and they stood behind him. When Jaabir and Jabbaar stood on his right and left, he pushed them until they were behind him, even though they were two. Similarly, Jaabir narrated: I travelled with the Prophet (blessings and peace of Allah be upon him) on a campaign. He stood up to pray, and I did wudoo’, then I came and stood on his left. He took me by the hand and pulled me around until he made me stand on his right. Then Jabbaar ibn Sakhr came and stood on his left, and he took both of us by the hand and made us stand behind him. Narrated by Abu Dawood. This is also the view of ‘Umar, ‘Ali, Jaabir ibn Zayd, al-Hasan, Maalik, ash-Shaafa‘i, and ashaab ar-ra’y.
End quote from ash-Sharh al-Kabeer (2/61)
In the answer to question no. 66017 we explained that it is mustahabb for the imam to stand in the middle of the row.
If the worshippers stand on the right of the imam, their prayer is valid, but if the imam stands in the middle of the row and they stand behind him, that is preferable.
Al-Bahooti (may Allah have mercy on him) said: If the worshippers stand with the imam, on his right, or they stand on both sides of him, that is valid.
End quote from Kashshaaf al-Qinaa‘ (1/486)
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said: It is valid for them to stand with the imam, on his right or on both sides of him. That is, if there are two or more worshippers, they may stand on his left or on either side of him, one on his right and the other on his left. That is preferable to them being on his right only, because ‘Abdullah in Mas‘ood (may Allah be pleased with him) stood between ‘Alqamah and al-Aswad, and he said: This is what I saw the Prophet (blessings and peace of Allah be upon him) do. So if there are two worshippers or more with the imam, there are three ways they may stand:
1.behind him, which is the best
2.on either side of him
3.on his right hand side only.
End quote from ash-Sharh al-Mumti‘ (4/264)
If they pray on his right, and it is possible for the imam to step forward, even a little bit, to indicate who the imam is, and so that no one will stand ahead of the imam, this is the Sunnah; the evidence for it has been mentioned above.
Al-Bukhaari (may Allah have mercy on him) included a chapter in his Saheeh entitled Chapter: He should stand on the right of the imam, in line with him, if they are two.
Imam Badr ad-Deen al-‘Ayni al-Hanafi (may Allah have mercy on him) said:
If they are two, i.e., the imam and the one who is praying behind him – and it is limited to that, because if it is two worshippers with an imam , the ruling is that the imam should step forward.
End quote from ‘Umdat al-Qaari Sharh Saheeh al-Bukhaari (8/404)
But if they form a straight line with the imam, their prayer is still valid, and is not makrooh, because there is an excuse.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked:
Sometimes we are in the trench and it is narrow, so the imam cannot stand in front of us to lead the prayer; rather we make him stand in the middle of the first row. Is that valid? If it is not valid, then where is the correct place for him to stand? Please note that if we pray outside, we may be shelled and die.
He (may Allah have mercy on him) replied:
It is Sunnah for the imam to stand in front of the worshippers, but if that is not possible because the place is cramped, then there is nothing wrong with him standing with them in the middle of the row.
End quote from Majmoo‘ Fataawa wa Rasaa’il ash-Shaykh (15/185)
And Allah knows best.