Trying to control temperature of hotend using PWM signal and MOSFET
connected the 12 V, 3 A supply to the drain of the MOSFET. And connected the Resistance heater of the 3D printer to the source and ground.


The MOSFET is damaged. If the gate is at $0V$, no current should be able to flow.

You're trying to use an N-channel MOSFET as a high-side switch. This is a bad idea, because it would require more than $12V$ at the gate to turn the MOSFET on properly. It would be better to set this up as a low-side switch so that the microcontroller can drive the gate directly. The MOSFET should go between the load and ground, not between the load and $+12V$.

The fact that you connected it like this is the very reason the MOSFET has been damaged. When the MOSFET is OFF, there is $0V$ across the heater. When the microcontroller starts to turn the MOSFET ON (by applying $5V$ to the gate, thus increasing $V_{GS}$ to above $V_{th}$), current starts to flow through the load and the voltage across the load increases. This in turn decreases $V_{GS}$, causing the MOSFET to turn off. You will end up with approximately $3V$ across the load and $V_{GS}=2V$. You've got $9V$ being dropped across your MOSFET and with a current of approximately $800mA$, the $7W$ of heat produced will quickly kill the MOSFET.