The sons in questions are indeed those of Victor Hugo - Charles and François-Victor. The two, along with Auguste Vacquerie and Paul Meurice, edited a magazine, l'Evénement, and one by one the four had run afoul of Napoleon III's regime, the two Hugos and Meurice for articles they had run, Vacquerie for attempting to relaunch the magazine after it had been ordered closed.
The opening two strophes condemn the judicial system that has sentenced the four and assures that they are in the right. The third strophe refers to the offending articles - one questioning limits on the applications of the laws on asylum, the other criticizing the handling of the execution of Montcharmont and capital punishment in general. The final two strophes offer consolation to the four, comparing their suffering to that of Christ and assuring that whatever they suffer will be recompensed in the heavens. (The information above is drawn largely from Matthew Josephson's biography of Victor Hugo and Pierre Albouy's notes in the Tome II of the Pléiade edition of Hugo's poetry.)
A quatre prisonniers, like the passion, subverts the temporal order. In this courtroom, the condemned bask in righteous glory while a low, foul, cold caricature of justice has its ugly nature laid bare to the view of God. The four have been judged - perversely; those who judge them will in turn be judged - legitimately - and found wanting. And those who suffer the indignities of a petty tyrant will see their name crowned in glory.
The titles of the books in Les Châtiments provide a sarcastic commentary on the different aspects of Napoleon III's rise. This particular poem comes from La religion est glorifiée, which tells us that this poem is not about justice, but about Judgment - the ultimate Justice with a very capital J. In Hugo's view, the little Napoleon is not merely a an arrogant dictator; he is a subverter of truth that the visionary Hugo detests for leading France away from its proper path to greater glory. This poem shows the extent of his fury.