I'd cut the stud in the centre of the proposed location at least 50mm (maybe 100) above the top of the cupboard and add a new noggin horizontally between the remaining studs.
This will allow you to locate the cupboard and give wiggle room. Once final location is sorted, again allowing a small gap, fit some short studs to meet the top and bottom noggin so that you have a frame larger than the cupboard.
If this is a bathroom then I'd add rock wool into the wall to absorb sound, and avoid the cupboard touching the back wall. add something to the wall behind the cupboard, insulation abut also a second layer of PB slightly off the back wall. If you wanted, you could use building adhesive to fix ply or something to the outside of the cupboard where it is in the void so that you could screw into it from the inside of the wall, hiding the fixings.
However that makes removal hard, so you could screw to a timber frame from the cupboard's inside and use screw covers.