If the one who is offering Prayer is greeted or spoken to, he may reply to the one who greets or speaks to him by making some motion. Sheikh Sayyed Sabiq states in his well-known book, Fiqh Us-Sunnah: If the one who is offering Prayer is greeted or spoken to, he may reply to the one who greets or speaks to him by making some motion.
Jabir said: The Messenger of Allah sent me somewhere while he was going to the tribe of Mustaliq. I came to him, and he was praying while on the back of his camel. [When] I spoke to him, he and Zubayr motioned with their hands. I heard him reciting and saw him gesturing with his head. When he finished, he said: “What have you done about the thing I sent you for? Nothing kept me from talking to you save that I was in Prayer” (Ahmad and Muslim).
`Abdullah ibn `Umar narrates that Suhayb said: I passed by the Messenger of Allah while he was offering Prayer. I greeted him and he responded to me by only signaling. `Abdullah said: The only thing that I know is that he said he signalled to him with his finger (Ahmad and At-Tirmidhi).
`Abdullah ibn `Umar said: I asked Suhayb, “How did the Messenger of Allah respond to the people when they greeted him while he was praying?” He said, “He would signal to them with his hand” (Ahmad, At-Tirmidhi, Abu Dawud, An-Nasa’i, and Ibn Majah). Anas said that the Prophet would signal while offering Prayer (Ahmad, Abu Dawud, and Ibn Khuzaymah). The same applies to signalling with one’s finger or hand or by nodding the head. All of these actions have been related from the Prophet (peace and blessings be upon him).