I'm afraid we are not that experienced in Unix part of SCOM monitoring, as we are currently fully focused on supporting Windows-based SCOM monitoring technologies (with Hyper-V, VMware Collectors on windows OS and Veeam Backup and Replication).
I'm not sure if it is possible to complete a script execution if SCOM agent is down. This is possible for Windows agent, we are actually utilizing this in a Health Service Configuration task for SCOM management service, in our MP you have to run it manually and in the process it actually restarts the Health Service from the separate process which task creates. However as far as I can see there is a command to restart the daemon for Unix (scxadmin –restart), so it's not necessary to fork into a separate process in this case and it may work out of the box.
I would recommend to check Microsoft documentation about the topic, but feel free to ask other questions we may be able to suggest something.