The ruling on one who conceals his faith
If a person conceals his faith for some reason, then even if it becomes known, he will not be killed either, because in the Quran Allah the Exalted called a man from the family of Pharaoh, who used to conceal his faith, a believer.
وَقَالَ رَجُلٌ مُّؤْمِنٌ مِّنْ آلِ فِرْعَوْنَ يَكْتُمُ إِيمَانَهُ
[Al-Mu’min: 28]
“A believing man from the family of Pharaoh, who used to conceal his faith, said.”