How to link the title adding a permalink?

Following your code strictly you’d want …

$dl .= '<dt><a href="'.get_permalink($wp_query->post->ID).'">' . $wp_query->post->post_title . '</a></dt>';

… but you are using the WP_Query object in a very atypical way. You are sort-of brute forcing your way through the Loop instead of using the methods and template functions built into the core. For example:

while ( $query->have_posts() ) {
    $query->the_post();
    $term_letter = strtoupper( substr( get_the_title(), 0, 1 ) );
    if ( $glossary_letter != $term_letter ) {
        $dl .= (count( $active_letters ) ? '</dl>' : '') . '<li id="' . $term_letter . '"><span class="subheading">' . $term_letter . '</span><dl>';
        $glossary_letter = $term_letter;
        $active_letters[] = $term_letter;
    }
    $dl .= '<dt><a href="'.get_permalink().'">' . get_the_title() . '</a>></dt>';
    $dl .= '<dd>' . get_the_content() . '</dd>';
}
$dl .= '</dl></li>';

Or at the very least you can replace $query->post-> with $post-> since the the_post() method resets the $post global to the next post in the loop each time it runs.