Anyone who follows the law before their morality is inherently an immoral person, by definition. I don’t want immoral people deciding my fate, so why would I be immoral deciding someone else’s fate?
And, yes, it is immoral to follow the law in this case. You are voting to intentionally hurt someone. If you don’t know if the hurt is balanced by the good of society, then you are risking hurting someone unfairly.
If I voted for something that got someone the death penalty, and I didn’t think they’d deserve it. I’d be committing murder. Just like a lawyer who knows their client is guilty is responsible for any hurt that person performs.
Anything else is just smoke and mirrors to try and justify an immoral action.