Check if `do_action()` in WordPress returns any result

One possible way could be to use PHP’s output buffering via ob_start() like so

ob_start();
do_action('my_hook');

$content = ob_get_contents();
ob_end_clean();

if (empty($content)) {
    // no output generated
} else {
    // had some output
}