For one, you can add a Portable Hook:
function portable_func($atts, $content = null) {
ob_start();
do_action('portable_hook');
return ob_get_clean();
}
add_shortcode('portable-shortcode', 'portable_func');
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
Now, you can add [portable-shortcode]
Shortcode in your posts, and then use hook portable_hook
in your Hook Element.
This should hook your script in your preferred location.