It's funny you used those two for your hypothetical examples, because it doesn't need to be hypothetical, that did actually happen to both of them.
Luckily in the Rock's case they caught it early on and just turned him heel on the RTWM in early 2003.
But in Hogan's case, when he first came to WCW he was getting booed so badly they had to edit out the boos and dub in a track of cheers. Flair wrote about how embarrassing it was. Luckily it was before they went live with Nitro so they had time to get him over a little bit, but he soon went stale again, hence the eventual heel turn with the NWO.
First of all, what I should have said was if Rock stayed babyface. If he stayed a face, he would have been booed just like Cena is today. Hell, I have seen archived internet post's of people who didn't like The Rock from the early 2000's and they were saying the same thing people say about Cena today. "Five moves, doesn't sell, always come back, pandering to the crowd."
With Hogan, it's an entire different story. Hogan was in WWE, and the world was built around him. The WWE was Hulk Hogan's world, it was his show. People were built up so he could beat them. His character of eating his vitamins and saying his prayers was synonymous with WWE. Than, he went to WCW. A world of old school wrestling, the world of Flair, Sting, The Four Horseman. It wasn't the world of larger than life over the top wrestlers. It was the world of grittier more old school wrestling.
The WCW crowd didn't fully embrace the red and yellow Hulk Hogan that was his character in WWE. His character in WWE was larger than life, but WCW wasn't about that. WCW wasn't built for and around Hulk Hogan like the WWE was. So, instead of trying to keep his face when he was being booed, they turned him heel. But he turned heel because the world's were different.