Sayyiduna Abdullah bin Umar, may Allah be pleased with them, narrates that the Companion of the Messenger, Sayyiduna Suhaib, may Allah be pleased with him, said: I passed by the Noble Prophet, peace and blessings be upon him, while he was praying. I greeted him with salam, and he, peace and blessings be upon him, responded to me by gesturing. The narrator says: I think he mentioned that he gestured with his finger.
Hadith Referenceالفتح الربانی / كتاب السلام والاستئذان وآداب أخرى / 8263
Benefits: … Allamah Sindhi Hanafi said: From the words "he gestures with his hand" (yushiru biyadihi), it is understood that responding to salam by gesturing with the hand does not invalidate the prayer, nor should it even be considered disliked (makruh). And Allah knows best.