بسم الله الرحمن الرحيم
If he is in his senses and understands what talaq is while giving talaq, then talaq will take place. But if he is not in his senses, then it will not take place.
Note: It is advised that if such a person gives talaq, it should be referred to any Shariah Panchayat where, after due research and investigation, they will give their ruling.
Allah knows Best!
Darul Uloom Deoband