What if there are only two men at the funeral prayer?:
If there are only two men at the funeral prayer, the imam stands in front and the follower stands alone behind him.
Abdullah bin Abi Talha (may Allah have mercy on him) reports:
إن أبا طلحة دعا رسول الله صلى الله عليه وسلم إلى عمير بن أبي طلحة حين توفي، فأتاهم رسول الله صلى الله عليه وسلم، فصلى عليه في منزلهم، فتقدم رسول الله صلى الله عليه وسلم، وكان أبو طلحة وراءه، وأم سليم وراء أبي طلحة ، ولم يكن معهم غيرهم .
“Umayr, the son of Sayyiduna Abu Talha (may Allah be pleased with him), died, so he called the Messenger of Allah ﷺ. He ﷺ came and led the funeral prayer for Umayr in their house. The Messenger of Allah ﷺ stood in front, Abu Talha (may Allah be pleased with him) stood behind him ﷺ, and Umm Sulaym (may Allah be pleased with him) stood behind her husband Abu Talha (may Allah be pleased with him). There was no one else there besides them.”
Imam al-Hakim declared this hadith “sahih (authentic) according to the condition of Sahih al-Bukhari and Muslim”, and al-Hafiz (may Allah have mercy on him) agreed with him.