Is there an option in the pairing program to set this?
Of course.
Different approved Swiss pairing programs will do this is different ways. You should check out the User Manuals for the different programs to see how this is done.
For instance, in the Vega program go to the File menu, Round Manager, Avoid Pairs option and you can specify groups of players who should not be paired against each other for certain rounds. Generally speaking this should not be done in the last round where one of the players is on more than 50% even in the case of Iranian v Israeli since this can affect prizes and important placings.
Algorithmically, is it done in such a way that these matches are considered played already (through some flag "playedAgainstEachOther=true") or in some other way?
This is a programming question rather than a chess question and does not belong here.