Apparently the is isn't actually against the law, per se, to join a foreign army, although US citizens are discouraged from doing so. However, if you serve as an officer in a foreign army, you may be asked to give up your citizenship. It gets a little gray if said army is hostile to the US.