Possibly, under certain circumstances
The current answers have raised valid points, but I believe that under some circumstances, such a simulation could indeed prevent a war by encouraging a diplomatic resolution to the conflict. Here are some things that would make this more likely:
1. General faith in the accuracy of the simulation
As noted by @SteveMoser, everyone involved has to have faith in the simulations. Therefore, experts from both sides of the conflict have to have full insight into the source code and execution of the simulation. This will decrease the chances that either party claims the simulation has been tampered with. Even better, all the details should to be publicly accessible to everyone. This part is extremely important. Without it, the following points start to lose their validity.
Here is our first major problem. As noted by @CortAmmon, for the simulation to be accurate, it has to know all the details (and military secrets) of each party. So, your premise implies that at least one side is willing to expose its military secrets. If you want to avoid this, and since this is science fiction/(fantasy?), maybe the scanner could scan the facilities of each party, then hide it in way that it can only be accessed for the purposes of the simulation. Of course, the simulation output itself would give away a lot. I think you'll need a supernatural element to the simulation, or some other well thought out plot device to make this work. It sounds tricky, but if you're a good science fiction/fantasy writer you might make it work.
2. The result is shown to the public
The public has a much lower tolerance for the horrors of war than the leaders of a country. If people see a simulation where people who could be themselves and their loved ones (including civilians, women and children) suffer death, horrible pain, having their homes destroyed and general trauma, they will object strongly. Since the program simulates everything, it would contain every single detail. Thus, it could output moving pictures of women and children being killed, sounds of bombs, the screams of dying children, the smells of corpses decaying in mass graves, and areal images of whole cities devastated.
Even seeing this occurring to the "enemy" population, people will probably object, out of general humanity and compassion. The reason war propaganda exists is because people generally don't want war. They need to be convinced. Such a simulation, especially if vividly showing details, will have the opposite effect of war propaganda. Even in a dictatorship, the government can't successfully carry out a war if the people (soldiers, policemen, factory workers, etc.) are utterly opposed to it.
3. The simulation shows terrible destruction
The war ends much worse than expected. For example, a large part of the population is wiped out. The economy and infrastructure are devastatingly damaged. Governments are hit hard. If the simulation shows these things, even the war hungry leaders may think again.
4. The simulation unexpectedly shows the aggressor losing
The simulation shows the following:
- The Republic of Agressivia (ROA), very sure of themselves, invades The Kingdom of Pacifistia (KOP). The latter would have liked to avoid a war at all costs, but decides to fight fiercely once invaded.
- It's a long and terrible war where millions die and utter destruction is done to infrastructure and the economy. Thousands of innocent women and children suffer terrible deaths, diseases, etc.
- After a long time of this horror, ROA are out of supplies, weapons and logistics, yet KOP is still holding out, defending their kingdom. The ROA has no choice but to pull out, and switch to defending their initial territory.
- Both countries are devastated, and KOP has not the resources nor the desire to counter-invade ROA. The situation invites for a permanent ceasefire and a diplomatic resolution based on pre-conflict borders.
If you were the government of ROA and saw this simulation, would you still want to invade?
It's rare that both sides want war. It's mostly one side pushing for the war, and another trying to avoid it. If the aggressor sees that they will lose the war, it would be insane of them to go on with the war. This, of course, requires that they have faith in the simulation and believe that it's accurate. But I belive this is indeed the case in the scenario outlined in OP.
I don't know if these are the circumstances you have in mind. But if you intend to write a story where a simulation prevents a war, then those are some of the circumstances which could make it more realistic.