In many schools the only way to opt-out without receiving significant grief for doing so is to claim a religious exemption to pledging to things. I saw kids receive perpetually refilling detentions for refusing to say the pledge, though at the time I found it weird that they would refuse.
Don't generalize. I had a few brushes with the administrations in middle and high school because I refused to stand for the pledge. Whenever I was forced to stand, I would look the other way in protest. Luckily the high school eventually just dropped the morning pledge altogether.