Display author name, outside the loop, if they haven’t published a custom post

author’s name or logged in user’s name?

can use global $current_user; or wp_get_current_user(); if the user is logged in.

if( is_user_logged_in() ) {
    $current_user = wp_get_current_user();
    echo $current_user->user_firstname;
}

for specific user role you can check $current_user->roles array.

Reference:
https://codex.wordpress.org/Function_Reference/wp_get_current_user
https://codex.wordpress.org/Function_Reference/get_currentuserinfo