How to customize the critical error message?

You can use the wp_php_error_message filter to customise this message:

add_filter(
    'wp_php_error_message',
    function( $message, $error ) {
        return 'My custom message.';
    },
    10,
    2
);

I haven’t tested to be sure, but I would assume that if the critical error that causes this message happens to be in the code of same theme or plugin that this filter is used in, or a theme or plugin loaded before it, then this filter would likely not apply.

If you want to change this message independently of your theme and plugins, this might be a good use case for a Must Use Plugin.