There are some cap companies that offer a program where they will send you the unsewn front piece of the cap, so that it can be screen printed and sent back to them for finishing. If using this route, be sure to allow enough time between for the fabrication of the caps after the printed fabric pieces have been sent.
For printing on finished caps, look for a specialized platen accessory that helps clamp the hat down during printing. Also, make sure to test whether the cap can be cured through the dryer at the temperature required to cure the ink. For certain heat-sensitive cap materials, a low-cure additive may be necessary.
Another method is to screen-print transfers that you can then apply to the caps using a heat press machine specifically for caps.