This is an interesting question. I don't think that justice is one of the key themes of this tale. This story says a lot more about the psychological impact of death on us as people and how we are shown to retreat into realms of fantasy and are able to deceive ourselves when facing death. It is clear that he is not being hung completely unjustly - he has tried to burn down Owl Creek Bridge and therefore has attempted to seriously hinder the war effort of the Union forces. Therefore it is not as if he has done nothing and has become a random victim of war. He has chosen to attempt an act of sabotage and is being punished for it accordingly. It is always difficult to consider issues of "justice" is such contexts - little justice seems to go on during war time.