They can. However, historically, this pressure has almost never been significant enough to bring an immediate change of the government's course even in democracies.
The Vietnam War committed 3,000,000 Americans, left 60,000 of them dead, and killed ~2 million in total. The losses were obvious and highly publicized. The US is generally considered a democracy. Vietnam wasn't of any special significance to the American people.
The anti-war protests started in 1964. By 1967, the war was highly unpopular. In 1968, the president changed, but still didn't end the war. Overall, it took 12 years of warfare and 9 years of protests, with 6 of them widespread, to get someone to run on an anti-war platform again, win on it, and actually end the war in 1973.
For a war that is fought over something important, like a country that is of particular cultural or defensive significance to the belligerent, the threshold in losses that would turn the public opinion against the war is likely to be higher.
For an autocratic regime to step down, the threshold in both losses and protests is likely to be higher than for a democratic election to tilt towards the anti-war candidate.
The cost of a forceful takedown of an autocratic regime - a revolution - is extreme. The Russian Revolution took about 10 million lives. A new revolution might be less bloody. However, even the bloodless 1991 revolution in Russia resulted in a population reduction of 2 million over the next decade, and 5 million if time lag is accounted for.
From a strictly practical standpoint, this means that a revolution is only justified for the population if the expected losses from continuing the foreign war are even higher. World War I, largely responsible for the Russian Revolution, hit the Russian Empire with 2 million casualties, but was feared to cause a lot more. In strategic terms, the revolution ended up causing more harm than it prevented, including in territorial losses.
Some of the 1990s effect will happen in Russia either way due to the sanctions and corresponding economic downturn. Estimating this loss at 2 million, versus 5 million for a repeat of the 1991 revolution, would arrive at a threshold of ~3 million as intolerable.
//P.S. Cold math aside, I would hope it doesn't come to that. For modern wars, civilian casualties tend to exceed military ones, so you'd be looking at 8-figure total deaths in that scenario.