Reference: I’laam al-Mu’aasireen bi-Fataawa Ibn ‘Uthaymeen – Page 425
Question: What is the ruling regarding wearing trousers?
Response: There is no harm in this, because the Prophet ﷺ said whoever is unable to find an izaar (a wrap around which covers the lower half of the body) then let him wear trousers. And whoever does not wear an izaar and [instead] needs to wear trousers, then let him wear those trousers which conform to the legislated requirement of covering the ‘awrah (private parts) [and in so doing, not being tight].
Likewise, whoever is in need of that due to medical reasons, whereby some people say “if I do not wear these short trousers, this may cause severe sweat rash”, then we say, there is no harm [in doing so] – wear [the trousers] and there is no [legislated] harm (penalty) upon you.