Rabbi David Zvi Hoffmann, in Melamed le-Ho'il 42, was asked:
At this time, in all places where Jews reside, [at the command] of the king and state every able bodied man has to enter the military and serve for one, two, or three years, and he will be compelled there to violate Shabbatot and Yamim Tovim. Is a Jew who fears God's word and observes all the Torah's Mitzvot required to do all that is possible to avoid the military service, so as not to come to Chilul Shabbat, or not?
His answer, after weighing sources in the matter, was:
And now we come to our matter: It is without a doubt that, that he may not escape by any means from the military [service], is more [important] than a Devar Mitzvah, for whoever does so causes, God forbid, a Chilul ha-Shem if it becomes known, and will bring evil upon Jews, for Jew-haters will say Jews aren't obeying state laws. As one who goes to the army on Sunday, Monday, or Tuesday, is not violating a prohibition, according to most Poseqim, even if it is certain he will [later] come to Chilul Shabbat against his will, and if he does so for a Devar Mitzvah, like saving Jewish lives, or any other Mitzvah, he may go on his own even an 'Erev Shabbat to the army, so much so if one does not go on his own, but is taken in accordance with state laws, is it obvious that one is not requied to escape it, even if it is certain he will come to Chilul Shabbat, as by escaping he can come to some pitfalls. Therefore, sit and don't do here is surely better than a Devar Mitzvah.
Also, if we say that he is required to escape, in order to avoid Chilul Shabbat, then all Jews would be required to do the same, and obviously most will fail to achieve their goal, and it will have caused a great Chilul ha-Shem for nothing. Therefore, it is better you "keep the king's command"( Kohelet 8:2), and maybe you will find favor in the eyes of commanders, and will be left to observe the Shabbat, and do what is right in the eyes of God and man, for one who comes to purify himself, he is helped( Yoma 38b). And if you perform you actions for the sake of Heaven, all will make peace with you, "dwell in the land, and cherish faithfulness"( Tehilim 37:3), and peace upon Israel.
( All translations are mine.)
To the point, he says:
- One may not dodge the draft
- One may join an army for a Jewish cause( to save Jews, or observe any other Mitzvah), even if it means he will come to violate Halakhah.
I don't know whether he would allow joining an army, under other circumstances( like where there is no draft, no fear of violating Halakhah, and there is no Jewish reason to do so).