Here is the Ngram
Looking at examples in Google Books, I think it usually means to look outandlish, do something bizarre—perhaps from the belief that the Druids/Picts/Celts painted themselves blue.
You paint yourself blue and stand before your enemy, fearsome, naked, blowing a horn, in hopes of frightening them into retreat.
U.S. News & World Report, Vol. 124, p.8 (1998, snippet view)
"OK. Suppose Laneer said to her, 'Miss Farley, for the good of the
business, I want you to strip, paint yourself blue, and go live in
a tree like a Druid. I don't want you to ask me why. Just do it. I am
depending on you.' How would she respond? Best Detective Stories of
the Year 1978 (snippet view)
The same principle applies to you. You could put a lampshade on your
head, paint yourself blue, and walk down Main Street singing
"Yankee Doodle." As long as you didn't get arrested, you would
probably eventually relax and learn that it doesn't matter what people
think of you. But this would be a pretty tough thing to do and I doubt
that you would ever do it. R. M. Rapee; Overcoming Shyness and
Social Phobia: a Step-by-Step Guide (1998)
The Blue Man Group—well, what can I say? When you paint yourself
blue, you're going to stand out. The good news is that you don't have
to go to that extreme to be successful. Lauron Sonnier; Think Like a
Marketer: What It Really Takes to Stand Out... (2009)
In the places where I was comfortable, whether honky-tonk, bohemian
ghetto or fraternity house, there was just one rule: if you want to
paint yourself blue and walk on your hands, go ahead, just don't suggest, don't even imply that anyone else should too. Even today, any congenial grouping of art and morality makes me break out in eczema. Dave Hickey quoted in Daniel Oppenheimer; Far From Respectable: Dave
Hickey and His Art (2021)
I looked to see if the Smurfs got involved, and, sure 'nurf, they did:
If you want to worship trees, worship trees. If you want to worship
the Smurfs and paint yourself blue, go ahead. Jocelyn Zichterman; I
fired God (2013)
Were the Picts Painted Blue?
Why did the Romans call these peoples the
painted ones? Did the Picts paint themselves blue, similar to Mel
Gibson in Braveheart? One thing we can be certain of is that Sir
William Wallace did not paint himself blue. The producers of
Braveheart were well aware of how widespread the idea of the Picts
painting themselves blue was. And a mere fact that William Wallace
came a thousand years later, would never stop them from going with an
arresting visual.
So, where did the idea about the Picts painting themselves blue
originate from? Julius Caesar once noted that the Celts got blue
pigment from the woad plant and that they used it to decorate their
bodies. There are no surviving historic accounts of woad being used in
Scotland to paint human skin. People have, nevertheless, tried testing
woad and found it much better at dyeing cloth than skin. Woad was, in
fact, widely used in the Middle Ages for all types of cloths,
including the tapestries. The Great Courses; "The Origins of the
Celtic Picts"