I don’t think there’s a way in the current macro system to determine whether the icon marker is set on that target, then to not unset if it isn’t.
However, a workaround may be to use the combat
conditional. This will only set (or unset) the raid icon while out of combat:
#showtooltip
/cast Judgement
/startattack
/stopmacro [combat]
/script SetRaidTarget(“target”, 8);