How can I use ‘edit_form_after_title’ conditionally?

It seems like it might be worth restricting your message specifically to the screens you want the message to appear on, rather than having it appear everywhere except a plugin page. The screen ids of “post” and “page” are self-explanatory; just add more “or” clauses with the double pipes and include any custom post types you want the message to appear on.

add_action( 'edit_form_after_title', function( $post ) {
$screen = get_current_screen();
if($screen->id == 'post' || $screen->id == 'page' || $screen->id == 'your_cpt_slug') {
echo "<div class=\"add-message\">
<p>Message.</p>
</div><!-- /add-message -->";
}
});

If instead you do want it to appear everywhere in the admin except your particular plugin screen ID, substitute that screen ID for ‘screen_to_hide_on’ below:

add_action( 'edit_form_after_title', function( $post ) {
$screen = get_current_screen();
if($screen->id != 'screen_to_hide_on') {
echo "<div class=\"add-message\">
<p>Message.</p>
</div><!-- /add-message -->";
}
});