I heard the Messenger of Allah ﷺ say, "When you pray over the deceased, make your supplication for him sincere."
حدثنا عبد العزيز بن يحيى الحراني حدثني محمد يعني ابن سلمة عن محمد بن إسحق عن محمد بن إبراهيم عن أبي سلمة بن عبد الرحمن
سمعت رسول الله ﷺ يقول إذا صليتم على الميت فأخلصوا له الدعاء
[Its chain of transmission is hasan] Ibn Majah reported it in "the Book of Funerals, Chapter on what has been said regarding the supplication in the funeral prayer," no. 1497, from the hadith of Muhammad bin Salama with the same wording, and Ibn Hibban graded it sahih, no. 754, 755. Ibn Ishaq explicitly stated that he heard it directly.