It's only treason if they wage war with the US
Treason is unique in American law: It is the only crime that is defined in the Constitution. It is made a crime in the US code (18 USC §2381) not "military law."
Following the Constitution's Treason Clause, USC §2381 has two prongs. To be guilty of treason, one must either:
- Levy war against the United States; or
- Adhere to its enemies, giving them aid or comfort.
Since this country is not at war with the US, the first prong does not apply. "Enemies" has been interpreted narrowly, to mean only enemies in a real war. Thus, one can only be guilty of treason in the US during wartime, so the second prong does not apply either.
The Founders defined treason narrowly and put it in the Constitution to de-politicize it. According to James Madison (in Federalist 43), in the past, “violent factions” had often used “new-fangled and artificial" definitions of treason to “wreck their alternate malignity on each other…” To keep from repeating this sorry history, the Constitution “opposed a barrier to this peculiar danger,” by defining what constituted treason and specifying how it was to be proved.
Exactly how narrowly treason is defined can be seen in the Supreme Court's 1807 decision in Ex Parte Bollman. This case arose out of the Burr Conspiracy, Aaron Burr's plan to carve a new country out of the US. Bollman was charged with conspiring with Burr. The Court ordered Bollman released. In his opinion, John Marshall explained why:
However flagitious may be the crime of conspiring to subvert by force the government of our country, such conspiracy is not treason. To conspire to levy war, and actually to levy war, are distinct offenses.
If you want to read more about treason, here's a short article by a law professor, and here's a nice overview of the topic from the Congressional Quarterly.
Denationalization: Another problem they probably don't have to worry about
If you are looking for reasons for these patriots to worry about joining the military of another country, treason is not the only legal danger they face. Volunteering in the armed services in another country's military can also lead to losing one's citizenship, even if that country is not at war with the US. During WWII, loss of citizenship was controlled by §401 of the Nationality Act of 1940. Under §401(c) US citizens could serve in foreign armed services if "expressly authorized by the laws of the US." Otherwise, the law only provided for the denationalization of any citizen who served in a foreign military in which he had or acquired nationality. The 1940 Act said nothing about serving as an officer or intending to renounce American citizenship. Those provisions were added in later Acts.
How to apply real law to an imaginary world
You will have to stretch the words of the Nationality Act of 1940 and the "Neutrality Acts* to get them to apply to this imagined situation. Instead of parsing these texts ever more finely in the hope you can figure out how to apply them to a situation those who passed these laws did not (and probably could not) imagine, a simpler and more direct approach would be to interpret these laws light of their purpose. The purpose of §401 of the Nationality Act is clear: If an American citizen shifts (or splits) his allegiance from the US to another country, he will lose his citizenship. §401 lists various acts that will be taken as evidence of shifting (or splitting) allegiance. So unless your guys do things that show they have changed their allegiance, they will be fine.
Keeping your guys on the right side of the Neutrality Acts might be a little trickier. Their purpose is simple: To keep anyone from dragging US into war before Congress declares it by making sure every American remains neutral between "belligerents." Unless you've built this world in such a way that the US could be easily dragged into a war on it, it seems your guys won't violate the purpose of the Neutrality Acts. (The Neutrality Acts are about "belligerents," so unless there's a war in this other world, the Acts probably don't apply anyway.)