All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
It is not obligatory on a praying person to respond to the greeting of Salaam during the prayer by gesturing; rather, this is only recommended.
An-Nawawi said, "It is not obligatory on him to respond to the greeting, but it is desirable to respond immediately by gesturing; otherwise he responds verbally after he concludes the prayer; this is the view of Ibn ‘Umar, Ibn ‘Abbaas, Maalik, Ahmad, Is-haaq, and the majority of the scholars…”
Ibn Qudaamah said:
"He (the praying person) responds to the greeting of the Salaam by gesturing… and if he responds to the greeter after he concludes the prayer, then this is good. This was narrated from Abu Tharr, ‘Ataa’, An-Nakha’i and Daawood, as Ibn Mas'ood, may Allah be pleased with him, narrated, 'I went to the Prophet and found him praying. I greeted him, but he did not return the greeting. I recalled what happened to me in the past and in the present. When the Prophet finished his prayer, he said to me, ‘Verily, Allah creates new commands as He wishes, and Allah has sent a fresh command that you must not talk during the prayer.’' He then returned my greeting."
The praying person responds to the greeting of the Salaam after he finishes the prayer even if the person who greeted him is not present [i.e. has left].
An-Nawawi said, "He returns the greeting after he finishes his prayer, whether the greeter is present or not…"
If he responds during the prayer with a gesture, then he raises his hand as if saying, "I heard it, but I cannot speak because I am praying." He raises his hand, whether he is in the standing position, or bowing, or prostrating. The scholars did not make any difference between these positions.
If someone greets you while you are reciting the Quran, then you may respond by gesturing like the one who is praying. It was also said that it is obligatory to respond verbally and then say Isti‘aathah again (seek refuge in Allah from the accursed devil), and then resume the recitation. Nonetheless, the scholars of Fiqh stated that it is disliked to greet someone who is reciting Thikr (expressions of remembrance of Allah), as he is busy mentioning Allah instead of responding to the Salaam.
Ibn Hajar said:
"As for the one who is engaged in reciting the Quran, Al-Waahidi said, 'It is more appropriate not to greet someone who is reciting Quran. In case one greets him, it is enough for him to respond with a gesture, and if he responds verbally, then he again seeks refuge in Allah from the devil and resumes the recitation.' An-Nawawi said, 'It is something that has to be looked at. It appears that it is permissible to greet him with the Salaam and that he is obliged to respond.' Then he said, 'As for the one who is engaged in supplication and is absorbed in it with an attentive heart, it is probable to say that he is like the one who is reciting the Quran. The preponderant view in my opinion is that it is disliked to greet him with the Salaam because it would bother him and it would be harder than in the case of (greeting with Salaam) the one who is eating.'"
Allah knows best.