Ok, I think I have more info now.
Anybody visiting your fort who doesn't plan on petitioning, will enter the map with unit.meetings.target_entity = -1 and unit.meetings.target_role = -1
Anybody who will eventually petition, will have the unit.meetings.target_entity = XXX, in my fort, this is set to 528, which some way identifies the mayor. It's not the mayor's id, hist_figure_id or hist_figure_id2. I know that much. I don't know if 528 is the mayoral position or what, but every visitor to my fort that has petitioned has had the target_entity set to this number upon entering the map.
Next: unit.meetings.target_role = 3
You can actually select this enum, which is MEET_WORKERS.
I had my civ's lord consort come onto the map. I set his unit.meetings.state = 2 (attend meeting)
It would show up as his current activity briefly, then cancel. However, I think somebody else was petitioning at the time. After that person was done petitioning, the lord consort immediately tracked down the mayor, and petitioned.
About to test again with the gorlak dancer..... who, shit, is leaving.... his idle_area_type keeps changing to 27 (HeadForEdge) (might be a better option than the .Forest flag, PatrikLundell, for your getlost script?)
....now to figure out what state is their "I wanna leave" state before he gets away.... ugh
His activity shows attend meeting, but the headforedge is overriding it. annnnd.... couldn't figure it out... but used Nolimit's method to force him into civ.
Tested my method above to force petitioning on a visiting baroness consort, she came right off the map edge, and headed immediately to attend meeting, and petitioned.
Solved.
EDIT:
The 528 number is my local government id. Super solved.
EDIT2:
----------------------------------
tl;dr
select unit
dfhack
gui/gm-editor
meeting
target_entity = local government id
target_role = 3
state = 2