These days they can even catch over stamping, I heard about some cases using xray to do it. So it's more trouble than it's worth to remove serials on new guns usually. For some reason I hear about almost no instances of peening to hide it, which is probably because you need to know the right size and pressure so it mostly makes sense at scale.
It's funny the number of criminals that run around with literally filed off serials and get themselves literally 10x the time on the gun charge as whatever else they caught for.
You can instead get a shitty gun bc some have badly done serials (speshul wepunz has done this before, but ofc then you have to shoot one lol), you can get an old gun, you can finish an 80% lower. But most criminals just steal or straw buy, or buy smuggled guns (the philippines is notorious for this).
Also just scratching the surface smooth is not enough, and most people screw that up. The stamping leaves strain marks in the metal under the surface, and these can be recovered from a completely smoothed surface.
For example https://www.horiba.com/int/science-in-action/raman-breakthro... and https://digitalcommons.wku.edu/cgi/viewcontent.cgi?article=2...
These are just the tip of the iceberg for recovery techniques.
The classic trick for removing serial numbers and foil attempts at recovery is to weld over. For guns this gets complicated because you're potentially altering heat treated parts that would need to be re-treated but that's doable. The kind of people who tend to own heat treat ovens tend to be the kind to ask questions but that would cost $$. There are many common and popular guns where the serialized parts are not mechanically significant enough to warrant special heat treating in which case weld away.
Welded over is trivial to recover the serial numbers. See the refs I posted for example.