Reference: Liqaa.aat al-Baab al-Maftooh – Volume 1, Page 25, Number 35
Question: If the deceased has been buried in the grave, is it permissible to pray [the janaazah prayer] over him?
Response: If the deceased has been buried in the grave, it is permissible to pray over him. And the evidence for this is that the Prophet ﷺ went out to the graveyard and prayed over the grave of the woman who used to sweep the masjid, and who had died and the Prophet ﷺ did not know about this.