If you are talking about the sheets you buy at the local home improvements, sure. The process is actually fairly straight forward, but uses a lot more foam than you would think at first. A lot of wastage
You will need the foam, a way of cutting it (I used a saber saw which made it go very fast), a sharpie, a surform tool (available at most hardware stores), sandpaper, and knives.
First mark out on the foam the curves aand straights you will be using. Then dut that out. If it will take more than one layer toreach your desired height, lay those pieces on the foam and mark the second layer under them and cut it out. Continues with this until you get the desired height. Make susre you allow a lot of room on each layer for future shaping, and also for any flat spots etc. you plan on putting in. Now take the various layers and assemble them using a contact adhesive or construction adhesive that is safe for foam.
Now the messy part, best done outside as the mess will get all over anything nearby. Take the surform tool and blend the various layers and form the rough contour you are looking for. This tool will make the work very fast. Now take the sandpaper and sand out any marks left by the surform. Finally use the knives to carve an any rockwork or special features. Paint appropriately and install on the railroad.
It would be a good idea to first practice by making a couple of small hills of 2 or 3 layers just to get an idea for how much room is needed for shaping.
Hope this helps.