US President Donald Trump is barring transgender people from serving in the military "in any capacity".