M9 or a Glock? I'm not too sure, but I know KJW has threaded outer barrels for their models that you can attach a silencer to. Theoretically you can do it to any gun, but if it has a moving barrel it will cause tremendous amounts of wear on your gun due to the extra weight on the end when it cycles. What you need is a handgun with a fixed outer barrel.
KJW Mk18 MOD1 BLOCK 2 - Well VSR-10 - Les Baer Ultimate Recon