The problem is that the sudo is applying to the echo command but not to the dpkg. As the command that requires elevation is dpkg --set-selections, you should be able set the flag with either of the following commands:
sudo sh -c "echo libglul-mesa hold | dpkg --set-selections"
or:
echo libglul-mesa hold | sudo dpkg --set-selections
The problem is that the sudo is applying to the echo command but not to the dpkg. As the command that requires elevation is dpkg --set-selections, you should be able set the flag with either of the following commands:
sudo sh -c "echo libglul-mesa hold | dpkg --set-selections"
or:
echo libglul-mesa hold | sudo dpkg --set-selections