Generally, the way that this is usually circumvented is by making up some fake country located in a similar area as the country that is being referenced. Usually this happens when the writer wants to touch on something that has happened in current events but wants enough slight of hand to not name the persons involved (but, given context, any contemporary reader knows what's being talked about). This has happened frequently enough that Tv Tropes even has four separate trope pages for these stereotypes: generic stereotypic Latin American junta, generic stereotypic Soviet or post-Soviet eastern European country, generic stereotypic warlord-controlled post-colonial African nation, and generic stereotypic Middle Eastern Islamic fundamentalist state. The reasons why are kind of obvious, given that usually these fictional countries are characterized as hotbeds of political corruption.
A good example of this can be seen in The Authority, which was an late 90s-early oughts comic that was basically "a more violent Justice League gets involved in modern geopolitical issues". One issue of The Authority had them intervening in East Timor, which is a real region and the issue at the time was referring to a real crisis in which Indonesia was trying to prevent East Timor from seceding by scorched earth tactics and UN peacekeepers from the West and other southeastern Asian countries got involved. It was intended to be a reference to contemporary events, but in reprints DC comics changed the setting to a generic location out of concerns of political sensitivity.
Generally smaller countries will get replaced with generic counterparts, but the Soviet Union and USA as a whole are left as is because there are really only one of each and it would look silly trying to replace them with another superpower unless you are going completely alternate history. Western European countries often get mentioned by name, generally because they have a history of allowing free speech. Notably some middle Eastern countries, particularly Iran, have been offended and called for violence against authors for things that may or may not be historical (in the sense that whether or not the event happened is debated, but the religious debate over their veracity goes back at least 1000 years). There are also some parts of history that certain cultures or countries consider offensive to talk about at all. Not just culturally/politically insensitive or unflattering depictions of those events, but any portrayal of that time period outside of a history book is considered offensive, even if the author belongs to that group. The point of this is even restricting yourself to things that actually happened in real life can get you in trouble.
Other times authors will just go heck with it and include real countries by name. Though I don't know how far countries will go in pursuing action against the author barring how many Middle Eastern countries don't like any depiction of Mohammed. Tom Clancy got criticized several times for using real-life countries and political events in his novels, and even supposedly got pulled aside for questioning by U.S. intelligence for accidentally reverse-engineering state secrets through thought experiments. Whether anything more extensive has happened to spy fiction writers is unknown to the author.
Sometimes differing approaches can get mixed up in the same work. For example in the Metal Gear series you have Zanzibarland, which is a fictional county located where IRL Tajikistan or Kyrgyzstan should be (it's mentioned as at the border between the former USSR, Afghanistan, and China). On the other hand years later in Metal Gear Rising: Revengeance, you have Abkhazia and its independence movement, which despite sounding like a generic fictional county actually exists.