The Prophet ﷺ used to reply to the greeting of salam aloud during the prayer; then this ruling was abrogated. The ruling now is that if someone greets a person who is praying, he replies to the salam with a gesture of his hand; he does not reply to the salam by speaking.
Hadith:
قال عبد الله بن مسعود رضي الله عنه كنّا نُسلِّمُ على النَّبيِّ ﷺ وهو في الصَّلاةِ فيرُدُّ علينا قبْلَ أنْ نأتيَ أرضَ الحبشةِ فلمّا رجَعْنا مِن عندِ النَّجاشيِّ أتَيْتُه وهو يُصلِّي فسلَّمْتُ عليه فلم يرُدَّ علَيَّ السَّلامَ فأخَذني ما قرُب وما بعُد فجلَسْتُ أنتظِرُه فلمّا قضى الصَّلاةَ قُلْتُ: يا رسولَ اللهِ سلَّمْتُ عليك وأنت تُصَلِّي فلم ترُدَّ علَيَّ السَّلامَ فقال: (إنَّ اللهَ يُحدِثُ مِن أمرِه ما يشاءُ وقد أحدَث أنْ لا نتكلَّمَ في الصَّلاةِ)
Translation:
Abdullah ibn Mas’ud (may Allah be pleased with him) narrates: We used to greet the Prophet ﷺ with salam while he was in prayer, and he would reply to our salam. When we came back from Abyssinia, we greeted the Prophet ﷺ with salam, and the Prophet ﷺ did not reply to our salam. So grief overtook me, and thoughts of all that was near and far seized me. So I sat down waiting for the Prophet ﷺ. When he ﷺ finished the prayer with the salam, I said: “O Messenger of Allah, we greeted you with salam, and you did not reply to that salam.” He ﷺ said: “Allah the Most High has sent down a new ruling, whatever Allah willed, and indeed that ruling is that we do not speak in the prayer.”
Replying to salam by speaking has been abrogated. So now, if someone greets a person who is praying, what is the way of replying to that salam?
Consider the following hadith:
اخبرنا قتيبة بن سعيد، قال: حدثنا الليث، عن بكير، عن نابل صاحب العباء، عن ابن عمر، عن صهيب صاحب رسول الله صلى الله عليه وسلم , قال:” مررت على رسول الله صلى الله عليه وسلم وهو يصلي فسلمت عليه , فرد علي إشارة , ولا اعلم , إلا انه قال: بإصبعه”.
The Companion of the Messenger Suhayb (may Allah be pleased with him) says: I passed by the Messenger of Allah ﷺ while he was praying, and I greeted him with salam, and he replied to me with a gesture. (Ibn Umar, may Allah be pleased with them both, says:) And I know only that Suhayb (may Allah be pleased with him) said that he ﷺ gestured with his finger.
Ruling on the hadith:
قال الشيخ الألباني: صحيح
قال الشيخ زبير على زئي: صحيح