Sunan an Nasai 828
The Book of Leading the Prayer (Al-Imamah)
أَخْبَرَنَا قُتَيْبَةُ، قَالَ حَدَّثَنَا حَمَّادٌ، عَنْ مُحَمَّدِ بْنِ زِيَادٍ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ مُحَمَّدٌ صلى الله عليه وسلم " أَلاَ يَخْشَى الَّذِي يَرْفَعُ رَأْسَهُ قَبْلَ الإِمَامِ أَنْ يُحَوِّلَ اللَّهُ رَأْسَهُ رَأْسَ حِمَارٍ " .
It was narrated that Abu Hurairah said:"Muhammad (ﷺ) said: 'Does the one who raises his head before the Imam not fear that Allah may turn his head into the head of a donkey?
Grading: Abu Ghuddah: Sahih · Al-Albani: Sahih · Zubair Ali Zai: Sahih Muslim
Text from the public-domain hadith-api dataset. Numbering follows that dataset and can differ by a few from some printed editions — check the wording, not only the number.