Paragraph (a) of the second clause of the Neutrality Act, 18 U.S.C. 959 [1], says that "Whoever, within the United States, enlists or enters himself, or hires or retains another to enlist or enter himself, or to go beyond the jurisdiction of the United States with intent to be enlisted or entered in the service of any foreign prince, state, colony, district, or people as a soldier or as a marine or seaman on board any vessel of war, letter of marque, or privateer, shall be fined under this title or imprisoned not more than three years, or both."
Specifically denying a single nation access to a globally provided service based on the request of a foreign power at war with that nation should be considered acting in their service.
However, this is only one of several illegal things Musk is accused of being connected to (Tesla car safety issues causing accidents, failure to pay/misleading creditors, etc.).