Yes, it is possible for one to get a shot off after being shot in the head oneself.
Here are two different examples, both involving cab drivers being shot in the head and still returning fire.
For the first example, see St. Louis Cab Driver Shot in Head, Returns Fire and Drives to Police Station for Help
This was a serious enough head injury that the cab driver was in critical condition in the hospital, but he still managed to return fire.
For the second example, see Cab driver shot in head returns fire, killing passenger
An argument ensued and the cab driver heard a bang and realized he had been shot in the back of the head.
The cab driver was able to pull out his own gun and return fire, killing Brooks.
See also CAUGHT ON TAPE: Officer Shot In The Head During Shootout, El Cajon where the officer stands up (from a kneeling position) and walks with his gun drawn after being shot in the head.
There are numerous examples of people driving after being shot in the head. One extreme example is Man Keeps Driving after being Shot Twice in the Head: Cops, where the cops pulled over a man for driving erratically only to find he was shot in the forehead and cheek.
Another example of returning fire is Savannah grandfather, shot in the head, shoots back
Two bullets hit Williams, one in his thigh, another in his temple.
"They tell me the bullet is going to be there," Williams said. "They're not taking it out, so it's still there."
The suspects fled when Williams pulled his own gun and started shooting back.

For a more-technical discussion, see Penetrating gunshots to the head and lack of immediate incapacitation. I. Wound ballistics and mechanisms of incapacitation and Penetrating gunshots to the head and lack of immediate incapacitation. II. Review of case reports.:
in the last century numerous publications reported sustained capability to act following penetrating gunshot wounds of the head...
This article discusses factors such as bullet mass, bullet velocity and the exact trajectory in the head.
See also Flaccid paralysis (shooting) which says:
Flaccid paralysis is a term used in tactical shooting when a headshot is taken and the bullet enters the cranial cavity in the "T-zone". T-zone shots are normally made in a situation where the suspect is armed and holding a hostage, usually at gun or knife point. The T-zone is roughly a T-shaped area from the outside of one eye socket to the outside of other eye socket and extending down the bridge of the nose to the upper lip. This area forms the "T" from which it derives its name. When the bullet enters the T-zone, it strikes the medulla oblongata causing flaccid paralysis. The advantage of flaccid paralysis is the subject is rendered incapacitated instantaneously preventing involuntary muscle contraction that may pull the trigger or cause other movements that may injure or kill the hostage. This is a difficult shot even by the best marksman and should only be attempted by trained personnel.
And similarly see When It Needs to Be One and Done: Aiming for the T-Zone in Hostage Situations
So basically just shooting the head can be ineffective due to either sustained conscious capacity after being shot or involuntary movement. There is a specific part of the head where shooting is likely to be possible without endangering a hostage who is at gun point, but certainly this would be difficult to achieve for a typical gun owner with a typical firearm.