Yes, you definitely can, however, the restriction would be the laws that are regulating firearms in your area. With this, please ensure that you get in touch with gun authorities before doing such a project. Technically, however, one can only ever safely powder coat a gun on its non-moving parts, such as the outside areas. The reason is that internal mechanisms of a firearm operate in almost exact tolerances and powder coating them may cause the device to malfunction.