To use an N-channel mosfet, the GPIO output to the gate has to be higher than the source voltage by at least the G/S threshold voltage of the mosfet. Otherwise the mosfet won't turn on. Also, I think at least some esp32's require that the ADC input be no higher than 1.1V. So you can pick your resistors to divide 4.2V down to 1.1V, and use the circuit below.
Or you can just forget about the mosfet, use high value resistors, and put a capacitor on the analog input.