Remove the link to a featured image if and only if it’s not a gif

If you want to check the mime type of the featured image, then one way could be to use get_post_thumbnail_id() to get it’s ID and then check the mime type with get_post_mime_type() :

if( has_post_thumbnail() && 'image/gif' !== get_post_mime_type( get_post_thumbnail_id() ) {
    return get_the_post_thumbnail();
}

where you return it for non-gifs.