Add a class to the anchor tag on HTML5 gallery

f you mean to add a class on the anchor image wrapper that you have added using wp-editor then you could
add folllowing code : this will filter the content and add class to your image

<?php    
function add_class_to_gallery($content) {

      $classes="gallery-link";         
      // check if there are already a class property assigned to the anchor
      if ( preg_match('/<a.*? class=".*?"><img/', $content) ) {
        // If there is, simply add the class
        $content = preg_replace('/(<a.*? class=".*?)(".*?><img)/', '$1 ' . $classes . '$2', $content);
      } else {
        // If there is not an existing class, create a class property
        $content = preg_replace('/(<a.*?)><img/', '$1 class="' . $classes . '" ><img', $content);
      }
      return $content;
}
add_filter('the_content','add_class_to_gallery');

And if you were trying to add a class to the feature image then you could use:

<?php if (has_post_thumbnail()) : ?>    
    <a href="https://wordpress.stackexchange.com/questions/265630/<?php the_permalink(); ?>" class="gallery-link" title="<?php the_title_attribute(); ?>" target="_blank"><img src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title_attribute(); ?>"/></a>
<?php endif;?>