Al-jawab billahi at-taufeeq (the answer with Allah's guidance)
It is permissible for a Mahram male and female to give or return Salam to each other.
However, regarding a non-Mahram male and female to give or return Salaam to each other will not be permissible. If Salaam was given then the reply should be in the heart and not audible.
When a strange [i.e. non-Mahram] women greets a man with Salam, he should answer her verbally loud enough for her to hear if she is an elderly women. However, if she is a younger women he should respond within himself. Likewise, when a man greets a [non-Mahram] women with Salam, the ruling would be the same … (Radd al-Muhtar 5:236).
However, giving Salaam and returning it will only be permissible when there is need or benefit in the interaction, and the interaction takes place within the limits of the Shariah and without fear of going beyond the limits and proprieties of the Sacred Law. (Ahsanul Fataawa Vol. 8 Pg. 42)