Discussion: House Dems Urge DOD, Joint Chiefs Of Staff: Don't Change Transgender Policy

Congress has the power to overrule the President on this. The President’s constitutional power as commander-in-chief is secondary to Congress’s constitutional power to make regulations for the governing of the armed forces:

US Constitution, Article I, Section 8
The Congress shall have power to … make rules for the government and regulation of the land and naval forces

Way back when, Bill Clinton announced his intention to allow gays to serve openly in the military. Congress quickly passed legislation prohibiting this. The compromise between the law and its implementation was known as “Don’t ask; don’t tell”.

Similarly, Congress can pass legislation prohibiting Trump from implementing his threat.

https://cmgajcluckovich.files.wordpress.com/2017/08/lk080617_color.jpg