Did you know all color photocopiers and printers sold have anti-counterfeiting technology? There are special patterns printed on bills that photocopiers and printers can detect and will refuse to print.
Most commercial printers, copiers, and print engines, but not "all"
So it was solved not by a law, and not by software that looks for anything resembling currency, but rather by placing a simple, easily software-detectable, pattern into all currency, and ensuring that anti-counterfeiting tools treat any currency lacking this pattern as fake money.
Okay, so now we just need to mandate the (mostly anonymous, decentralized) designers of printable gun CAD files to embed these special patterns into their open-source STEP and other CAD files, and then convince the open source printer and slicer software developers to include the detection code ...