Answered by Shaykh Ilyas Patel
For Hanafis, when one forgets to sit and say the tashahhud after the second rakat, then stands, then remembers, what does he do?
It has been stated in Nur al-Idah:
If an imam or individual forgetfully misses the first sitting (qa’da) of a fard salat, he will return back to the sitting (qa’da) position, unless he has stood straight. (unlike a follower (muqtadi) who is like a person who performs nafl or sunnah, as they will return back even though they stood straight).
If the above mentioned (imam, individual, follower or nafl and sunnah performer) returned back to the sitting position, and if they were closer to standing, then they will perform a forgetful prostration (sajda sahw) and if they were closer to sitting then there is no forgetful prostration (sajda sahw).
Ilyas Patel