The Gun Control Act (GCA), codified at 18 U.S.C. § 922(g), makes it unlawful for certain categories of persons to ship, transport, receive, or possess firearms or ammunition, to include any person:
…
who has been adjudicated as a mental defective or has been committed to any mental institution;
It is a crime.
https://www.atf.gov/firearms/identify-prohibited-persons