Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
According to the majority of scholars, if a person sneezes while praying, it is permissible for him to say Al-Hamdulillah whether the prayer is obligatory or supererogatory.
Answering your question about sneezing while praying, the Standing Committee for Academic Research and Issuing Fatwa, states:
If a person sneezes while praying, it is permissible for him to say Al-Hamdulillah whether he is offering obligatory or supererogatory prayer.
This is the view of the majority of scholars. It was also the view of Imam Malik, Ash-Shafi`i and Ahmad.
But they differed as to whether he should say Al-Hamdulillah silently or out loud. The correct view and the view of Imam Ahmad is that he should say it out loud, but only loud enough that he can hear himself, lest he distract other worshippers.
Evidence
That is the general meaning of the report narrated by Abu Hurairah that the Prophet (peace be upon him) said: “If one of you sneezes, let him say ‘Al-Hamdulillah‘ (Al-Bukhari)
Rifa`ah ibn Rafi` said: I prayed behind the Prophet and I sneezed and said: Praise be to Allah, much good and blessed praise, as our Lord loves and is pleased with. When the Prophet had finished praying he said: “Who is the one who spoke during the prayer?” and no one said anything. Then he said it a second time, “Who is the one who spoke during the prayer?” and no one said anything. Then he said it a third time, “Who is the one who spoke during the prayer?” and Rifa`ah ibn Rafi` said: It was me, O Messenger of Allah.
The Prophet said: “What did you say?” He said: I said: Praise be to Allah, much good and blessed praise, as our Lord loves and is pleased with. The Prophet said: “By the One in Whose hand is my soul, thirty-odd angels competed to see which of them would take it up.” (At-Tirmidhi, Abu Dawud and An-Nasa’i)
Al-Bukhari narrated this hadith but he did not mention that he said that after sneezing, rather he said it after rising from bowing.
It is possible that Rifa`ah sneezed while rising from bowing and he said that because he sneezed, and the Prophet approved of that and did not rebuke him for it.
Saying Yarhamuk Allah to a Praying Person
This indicates that it is permissible during prayer. But if a person sneezes while praying then praises Allah, it is not permissible for those who hear him to say Yarhamuk Allah (may Allah have mercy on you), because that is part of human speech and it is not permissible during prayer.
The Prophet denounced someone who said Yarhamuk Allah to a man who sneezed while praying, then he said to him: “In this prayer nothing of human speech is permissible. It is only tasbih (glorifying Allah), takbir (magnifying Allah) and recitation of Quran.” (Muslim, Abu Dawud and An-Nasa`i)
Almighty Allah knows best.
Source: www.islamqa.info