All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
It is permissible to ask the dying person to say the Shahaadah, regardless of whether he is a Muslim or a non-Muslim and whether he is a person who originally is a non-Muslim or an apostate.
Ibn ‘Uthaymeen said in Sharh Riyadh As-Saaliheen:
“The scholars said: If he (the dying person) says Laa Ilaaha illa Allah, then the person with him should keep quiet and not say anything. If he regains consciousness and says something like ‘give me water’ or anything else, then the person with him should again ask him to say the Shahaadah. But if the dying person is a Kaafir (disbeliever) apostate – and we seek refuge with Allah from apostasy – then perhaps we should command him to say Laa Ilaaha Illa Allah. Then, if Allah grants him success to say it, it is well and good, and if he does not say it, then he is a Kaafir... ”
We should point out that if a Muslim commits an act that takes the Muslim out of the fold of Islam, it is not permissible to hasten to declare him as a Kaafir unless the truth has been clarified to him, the evidence has been established against him, and the misconception has been removed from him, because if someone’s Islam is established with certainty, he cannot be declared a non-Muslim except with certainty.
For more benefit, please refer to fatwas 332269 and 15255.
Allah knows best.