Short answer? Go for it.
Don’t let anyone tell you otherwise.
You’ve probably heard someone tell you this by now. That they don’t want “politics” in science fiction, or horror, or Disney Princess fanfic. Of course we all know what they really mean. They don’t want you to write anything that disagrees with their personal politics.
It is in fact possible that if you include a strong political stance in your writing, you’ll lose a few readers. You might also gain a few more–who agree with you. Who want to support your message.
You may have been told that if you take a strong political stance in your writing, you’ll get harassed online. I’ve got news for you–you will get harassed online as soon as you put your name in the public eye. It’s something you learn to deal with as a writer. There will be angry words, and name-calling, and maybe even threats, regardless of what you say.
Politics is part of our daily life, maybe more now than at any time in the past (certainly more than any point in my lifetime). If your characters don’t have political views, they’ll feel less realistic.
And if you write in the most non-objectionable, most middle-of-the-road way, how will your story stand out?
I was told early on in my career to shy away from “controversial” subject matter. Like, for instance, having characters who weren’t straight, white, and predominantly male. I was given a very long lecture on this by someone I trust, someone with a lot of experience in the industry.
All I can tell you is–my two most successful characters were a lesbian state trooper and a Muslim schoolgirl from Somalia.
Whoever tells you to keep the politics out of writing is trying to stop you from using your voice. Don’t let them.