Change “logged in as a ” link in comments form

We could try to rebuild the HTML through the comment_form_logged_in filter, where the HTML is constructed by default as:

'<p class="logged-in-as">' . sprintf(
/* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */
     __( '<a href="https://wordpress.stackexchange.com/questions/276188/%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ),
     get_edit_user_link(),
     /* translators: %s: user name */
     esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ),
     $user_identity,
     wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) )
 ) . '</p>'

But since it’s rather complex and we might loose the translations, when rebuilding it, we might try to replace it (once) instead with e.g.:

add_filter( 'comment_form_logged_in', function( $html, $commenter, $user_identity )
{
  return preg_replace( '#<a href="https://wordpress.stackexchange.com/questions/276188/[^"]*" aria-label="https://wordpress.stackexchange.com/questions/276188/[^"]*">([^<]*)</a>#', '$1', $html, 1);
}, 10, 3 );

or with a DomDocument approach. See e.g. here.

Note that if the translation string changes in core, this might need adjustments!