Its probably from the prescribed shampoo.
Now his scalp is dry and itchy.
Don't use that again.
Also, with an infant, it is not necessary to wash their hair everyday.
Just a couple times a week is enough.
Or it will be too drying... on their hair and scalp.
That is what our Ped told us.
In between shampooing, you can just rub his head with a dampened wash cloth.
Also, does he nap?
Infants usually nap a a lot. 3 times a day is usual.
I also say this because you said he is s tired/frustrated/grouchy baby.
So maybe he needs to nap, more.
Also, for a baby, when they do things like that, it ALSO means, that they are:
1) yes, over-tired
and they do things like this to 'shut-out' external stimuli... and because they are tired and had enough.
He needs to nap. If he is not doing so, regularly. And consistently.
This is TYPICAL tired-baby behavior & 'communication.'
And give him a good solid feeding, before naps and when tired.
For cradle cap, per my son, we used olive oil.
To me, your baby is 'scratching' his head, because he is tired/over-tired/over stimulated and at the end of his rope.
Not because his scalp is itchy, per say.
But now, since the prescribed shampoo from the Ped, you do you have a baby with a TOO dry scalp. An irritated scalp.
So don't use that shampoo again.
all the best,