Not quite sure what you mean, since you basically already answered your own question, as I understood it.
The only thing I see is that you should remove the at each part of the if statement, because the code inside is also php.
<?php
if (is_user_logged_in()) {
$term_list[] = '<a href="' . get_term_link( $term ) . '">' . esc_html( $term->name ) . '</a>';
} else {
$term_list[] = esc_html( $term->name );
}
?>