Place some vehicle to act as the flag. Attach two AI on it looking at each other (examine the portal gun script) When a AI is inside that, attach the vehicle to them.
To make the AI go to the flag vehicle where ever it is, use this:
(ai_go_to_vehicle [ai] [unit] [string])
(thats why its a vehicle)
When the vehicle is attached, make the person its attached to head back to base, and leave the rest of the AI still trying to go to the vehicle (then he has people protecting him, etc, or ready to grab it on his death, etc. Probably want some AI that don't care about the flags existence that just run around to reek havoc so you don't just bomb the swam to kill everyone)
If its attached to someone, and they are dead, detach the object from them.
Since you don't want them using weapons during this time when carrying the flag, since player_add_equipment spesifies unitr, I see no reason why it wouldn't work on AI instead of only players
(player_add_equipment [unit] [starting_profile] [boolean])
When they get to their base, just do a volume test for the vehicle and if the vehicle is there, (game_lost)