How do I add class to an admin comment?

One way to add some custom class to a li tag if the comment was posted by an administrator is to replace line

<li id="comment-<?php comment_ID() ?>">

with

<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">

This will add support for the default WP comments classes to your comments callback.

Once you do that add in your theme functions.php file the code below it will add class “posted-by-admin” to the li tag classes if the comment author is an administrator.

add_filter( "comment_class", function( $classes, $class, $comment_id, $comment ) {
    if( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) && user_can( $comment->user_id, "administrator" ) ) {
        $classes[] = "posted-by-admin";
    }
    return $classes; 
}, 10, 4 );