No, this does not work.
I have explored all the automation configuration.
There is no way we can change the status of relay when the magnet contact closes.
The event types we have are Alarm, Disarm, Arm, Manual, silence alarm, schedule.
Let's assume you set the relay to Latch NO for alarm...