You cannot execute theme code unless it is activated, even it is to abort activation, so you’d really be activating, checking for the plugin, then switching back if the check fails.
Untested, but I think you could use the “after_switch_theme” hook to execute such code and call
switch_theme() to restore the previous theme if the check fails.
The problem I see is in putting up an alert if it’s to be the typical WP message box. When you switch back to the old theme, such a message would disappear when the page reloads. The message would need to be a true alert box that requires user interaction before proceeding. It would in fact initiate a restore old theme theme request. If the user should ignore it and simply close the window, your code would not know to switch back.
Your theme could maybe save the old theme’s reference when the plugin check fails. If the setting still exists on the next request, via an “init” action callback, you could then force switch back to that previous theme after first removing the reference. If the user does acknowledge the message, remove the reference and switch back immediately. Then the “init” callback wouldn’t be needed.
Random thought here is you could also look at the core themes and see how they handle version comparison to get an idea of how to do that too and maybe use the function
is_plugin_active() to check.