There are legal ways to create cryptocurrency, but it has to be done in a legal manner.
Creating a cryptocurrency is subject to various kinds of regulation.
In particular, an "Initial Coin Offering" is typically regulated in the United States as an offering of a security and regulated that way. Lack of proper regulatory compliance could constitute marketing an unregistered security. Consider, for example, this press release from the U.S. Securities and Exchange Commission:
Unregistered ICO Issuer Agrees to Disable Tokens and Pay Penalty for
Distribution to Harmed Investors
Washington D.C., Sept. 15, 2020 —
The Securities and Exchange Commission today announced charges against
Unikrn Inc., an operator of an online eSports gaming and gambling
platform headquartered in Seattle, Washington, for conducting an
unregistered initial coin offering (ICO) of digital asset securities.
Unikrn agreed to settle the charges by paying a $6.1 million penalty,
substantially all of the company's assets, to be distributed to
investors through a Fair Fund.
There could conceivably be other regulatory requirements or violations of the law, depending on how the crypytocurrency was designed, was used, or its part in a larger plan, but this is highly fact specific and can't be answered in the general case.