No, it didn't give them the right to kill him. Hernandez gave them that right, when he decided to compound his crimes with throwing rocks. We're not talking pebbles, we're talking weighty projectiles, intended to inflict serious harm, possibly death. He continued throwing even after being warned that the targets were government agents.
That action is what gave them the right.