If you have the option of handing over the holster, too, that should legally prevent the officer from running the number.
If you're wearing the gun, though, the officer probably isn't going to allow you to mess around with taking the holster off. He'll want you to keep your hands visible while he unholsters your firearm for you.
I thought about putting some electrician's tape over the serial numbers, until I realized there's a copy of the SN on the chamber, visible through the ejection port. That can't be covered without affecting the performance of the gun, and of course it's illegal to remove or damage the mark.