The funeral prayer is to be offered for one upon whom a legal hadd punishment has been carried out
➊ In a narration from Jabir (may Allah be pleased with him), a man confessed to adultery, then he was stoned until he died:
فقال النبى صلى الله عليه وسلم خيرا وصلى عليه
“The Prophet ﷺ said good words about him and then led the funeral prayer for him.”
➋ The Prophet ﷺ commanded that the woman from Ghamid be stoned until she died:
ثم صلى عليها
“Then he ﷺ led the funeral prayer for her.”
(Shawkani, may Allah have mercy on him) There is consensus on (the permissibility of) offering the funeral prayer for one who has been stoned.
(Nawawi, may Allah have mercy on him) He quotes the statement of Qadi ‘Iyad: “The position of all the scholars is that the funeral prayer is to be offered for every Muslim, whether a hadd punishment was carried out on him, he was stoned, he committed suicide, or he was a child born of adultery.”