Amplify PWM Signal from exactly 0-3.3V to 0-5V
2N7000 won't be fully turned on with 3.3V Vgs so it is unable to pull the output to ground, there will be a residual voltage as you noticed.

You can use a 74HCT logic gate for 3.3V to 5V logic level conversion. Your can use any gate you want like a 74HCT08 AND gate with both inputs to the same signal.







simulate this circuit &ndash; Schematic created using CircuitLab

Depending on the output current you want, you can also put all 4 gates in parallel. If it's just to drive a logic level input, no need to.

If the cable is longer than a few tens cm, add a 33R resistor at the output of the gate to avoid signal reflection.