Mishkat al-Masabih 1020
وَعَنِ الْمُغِيرَةِ بْنِ شُعْبَةَ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِذَا قَامَ الْإِمَامُ فِي الرَّكْعَتَيْنِ فَإِنْ ذَكَرَ قَبْلَ أَنْ يَسْتَوِي قَائِما فليجلس وَإِنِ اسْتَوَى قَائِمًا فَلَا يَجْلِسْ وَلْيَسْجُدْ سَجْدَتَيِ السَّهْو» . رَوَاهُ أَبُو دَاوُدَ وَابْنُ مَاجَهْ
From al-Mughirah ibn Shuʿbah, who said: The Messenger of Allah ﷺ said: "When the imam stands up after two rakʿahs, if he remembers before he is fully standing, let him sit; but if he is fully standing, let him not sit, and let him perform the two prostrations of forgetfulness." Reported by Abu Dawud and Ibn Majah.