The tweet from the Canadian Armed Forces' official account included a photo of military band members marching in a parade with rainbow flags fluttering from their instruments.
"We welcome Cdns of all sexual orientations and gender identities. Join us!" said the tweet, which included the hashtag #DiversityIsOurStrength.
Within an hour, it had been retweeted 2,500 times.
Trump's surprise announcement, in a series of Twitter posts on Wednesday, drew condemnation from rights groups and some lawmakers in both US political parties as discrimination with purely political motives. But it was praised by conservative activists and some Republicans.
The action, reversing Democratic former President Barack Obama's policy, halted years of efforts to eliminate barriers to military service based on sexual orientation or gender identity.
Related reading
Trump bans transgender people from US military
The Canadian military's social media response to Trump's move was reminiscent of a tweet by Canadian Prime Minister Justin Trudeau in January after Trump issued a travel ban affecting people from Muslim-majority countries.
"To those fleeing persecution, terror & war, Canadians will welcome you, regardless of your faith. Diversity is our strength," Trudeau tweeted at the time.