It is narrated from Ubaidullah bin Adi bin Khiyar that a man whispered to the Messenger of Allah ﷺ; we did not know what he whispered to you ﷺ, until the Messenger of Allah ﷺ spoke loudly, and it became clear that he was seeking advice about killing a man from among the hypocrites. So the Messenger of Allah ﷺ said: "Does he not bear witness that there is no deity except Allah?" The man said: Yes, but his testimony will not benefit him. You ﷺ said: "Does he not perform prayer?" The man said: Yes, but his prayer is of no use to him. The Prophet ﷺ said: "These are the people whom Allah has forbidden me to kill."
Hadith Referenceمسند الإمام الشافعي / كتاب القتل والقصاص والديات والقسامة / 1602
Hadith Takhrijاخرجه البيهقي: 376/3 - واحمد: 5 / 433 - وعبد الرزاق (18688) وصححه ابن حبان۔