The transistor needs to be connected with its emitter tied to ground, called "common emitter".
As you have it, in a configuration called "emitter follower" or "common collector", the emitter of the transistor is always 0.7V below the base, and since the base never rises above +3.3V, the emitter can only reach +2.6V. That's not even close to what you require at M1's gate.
In the following circuit, M1's gate is +5V when the ESP32 output is low (0v), and 0V when that output is +3.3V:
simulate this circuit – Schematic created using CircuitLab
To switch the motor on, you require a low output from the ESP32.
R2 prevents the motor from running before the ESP32 has configured its ports, by gently holding that output high.
Update:
I just noticed that you can further improve this by connecting the top of R3 to the +12V supply, instead of +5V. That way, M1's gate can rise to 12V, easily enough to get the best (lowest) possible drain-source resistance \$R_{DS(ON)}\$.