If I write a really bad, but controversial, paper, can I increase my h-index? Imagine that I write a paper about a controversial topic like global warming denial, the link between vaccines and autism, why different races have different IQ. After publication, the paper gets the attention of mass media, and as a counter measure, serious experts start explaining why the paper is completely wrong. 

Would that count as citations towards a higher h-index?
Yes, you can!

But that it is possible is by no means to say that it is ethical, practical, wise, or otherwise commendatory. I would be especially concerned about becoming known as the 'person with a kooky idea' rather than as a serious academic researcher. 

The question becomes, "It is possible to write on a very controversial topic, create a media firestorm, attract a lot of attention, increase your h-index, and still keep your credibility intact?" The answer will be highly variable dependent on the validity of your research, your previous reputation, and the sheer capriciousness of luck. 

First, assuming that your work is valid,  even if you have proven the viability of a very controversial position, your work is likely to attract some negative attention as well as attempts to disprove your research (or you-- ad hominem attacks are unfortunately common). However, if your work can and does stand up to scrutiny, all the brouhaha may actually work in your favor-- you have proven a controversial theory to be true, your h-index will increase and your credibility is not only intact but also bolstered by your success. 

On the other hand, if your work does not stand up to scrutiny (which seems to be the scenario you are picturing), you will have made a public fool out of yourself and the slight increase in your h-index will be more than offset by the decrease in your credibility. Neither the counter-moves of serious researchers nor the attacks of fanatics are likely to help your academic career, especially if your work cannot stand up under scrutiny. 

So, write a really bad, but controversial, paper only if you are willing to sacrifice your credibility for the slight increase in your h-index.