How do I override a RenderElement? There is a Drupal 8 RenderElement called HtmlTag, which controls how HtmlTags are rendered. I would like to override this so that I can change its default behaviour.

I could write a class that extends HtmlTag and override what I need, but then how would Drupal core and the theme system know to use my new class?

Alternatively, maybe I should be using hook_theme_registry_alter() to tell Drupal 8 to use my new class?

I'm not really sure of the best way of achieving this and there don't seem to be any examples of this being done.
Using hook_element_info_alter() would be one option, not sure it's the best. 

The existing class sets 2 pre render callbacks, which you can override in your own class:

function MYMODULE_element_info_alter(array &amp;$types) {
  $types['html_tag']['#pre_render'] = [
    [\Drupal\mymodule\HtmlTag::class, 'preRenderConditionalComments'],
    [\Drupal\mymodule\HtmlTag::class, 'preRenderHtmlTag'],
  ];
}

...

namespace Drupal\mymodule;

use Drupal\Core\Render\Element\HtmlTag as CoreHtmlTag;

class HtmlTag extends CoreHtmlTag {

  public function preRenderHtmlTag($element) {
    // ...
  }

  public function preRenderConditionalComments($element) {
    // ...
  }

}