"He gave her a gesture while leaving the room." - Is this sentence correct?
Solution 1:
The sentence in question
He gave her a gesture while leaving the room.
is certainly grammatical.
The phrase give a gesture is not idiomatic, however, and not a spectacularly helpful description, since it doesn't include the communicative intent of the gesture. As other comments have made clear, people use gestures for all kinds of purposes, and if this is sposta be a description, it's not doing the job.
This is very much like saying
He said a sentence to her while leaving the room.
The reader's reaction to this sentence is likely to be something like
"OK, and ...?"
because it's the meaning of the sentence, or the gesture, that's likely to be important to the reader, not the physical description of the event.
Solution 2:
The idiomatic form is made a gesture to her (or more rarely, made her a gesture) and not gave her a gesture. You could use gave her a signal or gave her a sign.
To me, gave her a gesture sounds like a euphemism for gave her the finger. If you want to convey a positive meaning, you should use made.
Solution 3:
I would say He gestured to her as he left the room if you don't want to specify exactly what it was that he did; remember that a thumbs-up and a middle finger are both gestures, and (in American usage, anyway) have almost exactly opposite meanings - so you are leaving things quite open to the reader's interpretation.
If you want to unambiguously state that he was giving a positive signal to her - and that it was by means of a facial expression - I think I would go with:
He winked at her as he left the room.