Assuming you’re referring to the type of soft foam used to cushion and protect firearms during transport, there are a few ways to cut it. The simplest is probably to use a sharp knife or a box cutter. Just be careful not to damage the firearm in the process.
Another option is to use a hot wire foam cutter. This is a wire that gets heated up and then passed through the foam, slicing it cleanly. Hot wire cutters can be purchased online or at some hobby stores.
If you need to make precise cuts or intricate shapes, you may want to consider using an industrial cutting machine like a water jet cutter or laser cutter. These machines can be expensive to purchase or rent, but they’ll make quick work of even the most complex cuts.