I am guessing this may all depend on the type and size of the foam. I can say that I have heated (with a heat gun) foamies and shaped them quite easily. There was no real technique, just heat it a bit, shape it, heat a bit more, shape a bit more, until I got the shape I wanted.
There are FAR more experienced voices on here than mine however. Give em time and they'll ring in.