You should push the nail back in, then drive a screw into the drywall right next to the popped nail, and mud over both the old nail and the new screw. A couple of little tips:
Hammer in the nail with the back of a nail punch (image below). If you just hammer it, you are likely to make a bigger hole in the drywall.
Don't try to make the new screw flush with the drywall. Dimple it just below the drywall
...»
facing (you should be able to set a good drill to dimple every screw to the same depth).
Make sure to use a studfinder (or the knock test) to find the stud and ensure you drive in the new screw on the stud.
Hammer in the nail with the back of a nail punch (image below). If you just hammer it, you are likely to make a bigger hole in the drywall.
Don't try to make the new screw flush with the drywall. Dimple it just below the drywall ...»
Make sure to use a studfinder (or the knock test) to find the stud and ensure you drive in the new screw on the stud.