Think of a famous scientist and you'll think of a brave soul who ran exactly against the "consensus" of the time.
I've got no issue with genuine scientists who go against the consensus on global warming, or any other issue, if they do so based on evidence and rational analysis, and they're open to being wrong if it turns out their contrarianism doesn't line up with the facts.
For example, there was a point not so long ago when quite a few good scientists were speculating that the apparent instrument record of global warming was just an artifact of growing "heat islands" that were causing localized warming of some of the thermometers in newly urban areas. That was an imaginative attack on the consensus, and they should be praised for it, because those kinds of challenges are an important part of how false consensuses are brought down and true consensuses are further underscored.
Their speculation could be tested. For example, you could re-compile the data using only the very best sites -- sites where growing heat islands couldn't be the problem. Then you could compare the pristine-site data with the data from all the sites, and see if there was a meaningful difference.
Scientists did exactly that, in response to that criticism. They recrunched the numbers for the US, using only the best sites, creating a "reference network" of the pristine sites, against which to compare the historical network's data, which had the possible heat-island artifacts. It turns out that the pristine-site data and the overall data matched up almost exactly:
So, at least in the US, the speculated impact of heat island growth didn't end up being a thing.
Since that's just the US, one might wonder whether it's something odd about this country, and growing heat islands elsewhere account for observed warming there. This has been tested in various places, including the the UK and Austria. The following graphs show temp trends in various locations over time:
What you'll see is that the urban areas are warmer in absolute terms, as expected, but each area, urban or rural, follows the same regional warming pattern over time. This isn't what we'd expect to see if apparent warming were just a result of cities growing into former rural areas. It's what we'd expect if there were real warming that was hitting both urban and rural areas.
Yet, still there were questions about whether that impact would show up in places like China, where cities were growing incredibly quickly, so that the heat island growth would be the biggest. Turns out, no:
Again, there just aren't big enough differences between the different data sets to account for the warming trend, or even any significant part of it. Whether you're measuring urban or rural, pristine sites or all the data, US, UK, Austria, or China, you get the same basic pattern in each location.
The point here is that there was nothing wrong with scientists trying to undermine the consensus with speculation about growing heat islands. That was a valuable part of the scientific process. They asserted an alternate, testable theory about what was happening, and that's a good thing. Then scientists went out and performed the tests to see if they were right, and it turns out they weren't. No shame in that. What would be shameful is if people clung to that explanation even after it became crystal clear that none of the data looks the way it would if the explanation were right. Then it wouldn't look like genuine scientists honestly seeking alternate explanations -- it would, instead, look like denialists closing their eyes to evidence because they want the answer to come out a certain way.
As time has gone on, the consensus has broadened and deepened, as to its basic ideas. It has done so because of the kind of work I explained above -- competing ideas keep getting brought up, tested, and discarded, thanks to the data. Maybe someday that will change, and someone will come up with a competing theory that explains the available data even better than the current consensus theory does. And then the consensus will start to change. But, for now, we're not there. Where we are is a place where lay people like you and me have a choice. We can start to guide public policy with a working assumption the vast majority of experts are mostly right. Or we can refuse to do so, because we find it more emotionally appealing to assume they're wrong.
For my part, I favor letting the science guide policy. I think that societies that are in the habit of allowing strong and enduring scientific consensuses guide policies end up right a lot more often than they're wrong, and they come out ahead in that process. I think societies that go the other way (e.g., South Africa embracing HIV denialism, or the Soviet Union embracing Lysenkoism) tend to suffer for it. So, until something better comes along, I advocate setting public policy with the expectation that the consensus scientists are right. We don't have to be married to that notion, but it should guide our actions until something better comes along.