I have it in mind to sit the washing machine on some dense foam with a plywood board on top to minimize vibration
This will probably reduce vibration transmission and stop the vibrations rattling other things and producing noise. But as pointed out above it could pogo about. You can instead buy rubber feet or pads specifically for this purpose.
but also thought I could line the sides of the cupboards with some form of sound proofing to further reduce any noise.
Foam* or something similar on the interior of the cupboard may reduce the noise level inside the cupboard slightly. However, the key thing is a solid, sealed enclosure first.
Talking in broad principles:
Enclosures are lined with absorptive material to stop resonances of the air volume inside the enclosure itself. They do not stop transmission of sound through the enclosure walls.
Transmission through the enclosure walls is stopped by the mass and density of the walls and all gaps being sealed.
Heat build up might be a problem. The machine manufacturer will have recommendations on minimum distances.
*For any foam to be suitable, it has to be of open cell construction.