Annievee, depends on the thickness. But most thicker foam can be compressed with a board and then cut with a utility knife.
Pumpkin Sundae, considering the cost of flex foam or Bosal, I would not be using it in a pet bed. I just finished making a new bed for our dog. I filled a pillowcase with small scraps and cut up pieces of batting. I covered that with a heavy duty plastic bag. Then I made a cover that has a zipper. The cover can come off for washing, the plastic can be wiped down with disinfectant, and the filled pillowcase does not need to be washed or dried.