Showing off personal beliefs through a “radical” appearance in the hope of eliciting a response from strangers.
That's a particularly emotionally charged view on this. I think you're spot on for those wearing MAGA hats, as openly declaring one's political beliefs is hard to view as anything but as a hope to elicit a response from strangers, but equating that with rainbow hair is quite the stretch. Have you ever considered that those with rainbow hair might have it to signal to their own in-group that they are queer because this is not something immediately visible and can be a way to find community? Greasers, hippies, and punks also can widely follow this reasoning/purpose behind "flagging" oneself.