All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
It is not permissible for the Muslim to say “Yarhamukallaah” (i.e. may Allaah have mercy upon you) to the sneezer during prayer, and whoever does this deliberately while aware of the ruling, his prayer is invalid. That is because saying “Yarhamukallaah” to the sneezer involves talking with a human and when this happens deliberately while the praying person is aware of the prohibition, it invalidates his prayer.
Once a the companion, Mu‘aawiyah ibn Al-Hakam As-Sulami said “Yarhamukallaah” to a sneezer during the prayer, the Prophet, sallallaahu ‘alayhi wa sallam, said to him: "People's talk is not permissible during prayer because it involves only Tasbeeh, Takbeer and recitation of the Quran." [Muslim] However, the Prophet, sallallaahu ‘alayhi wa sallam, did not order him to repeat the prayer because he was unaware of the ruling.
Allaah Knows best.