yes and no.
because you could hit people with the gun even when you had ammo.
It would basically be a whole other weapon. Also you would have to make another pickup for this melee version and overlap it with the shooting pick up. And obviously if you collected a weapon from an enemy you would only get the shooting, and not the melee version.
So yes it can be done.
But no it won't be a propper job!
"It's often better to keep your mouth shut and let people think you're an idiot, than to open it and confirm their suspisions" - Noel Coward