Would this circuit work properly?
No. You are applying 12 V to the 5 V supply input of the ESP32 module, which will blow it up. You need a voltage regulator or DC/DC converter to drop the 12 V down to 5 V.
Do I need to change the transistor (PN2222) to a MOSFET (IRLB8743PBF)?
Yes. The solenoid draws 12.96 W / 12 V = 1.08 A. PN2222 is rated for 600 mA absolute maximum, so it is nowhere near sufficient. IRLB8743 can handle the current easily, but it is designed for 4.5 V or higher Gate drive. Since the ESP32 only puts out 3.3 V you will probably need a level converter to provide sufficient Gate voltage.
Solenoid force varies between 30N,59N. How can I control the force of
the solenoid via the ESP32?
Solenoid force varies as it moves through the stroke, generally getting stronger as it reaches the end. You can vary the current using PWM, but that can only make the force less than it is normally, eg. at 50% PWM it would vary from 15N to 30N.