Select all checkboxes of an entity reference field on creating a node
Ended up resolving this issue with the following code: 

(function ($, Drupal) {

  /**
   * Check/Uncheck all checkboxes.
   */
  Drupal.behaviors.selectAll = {
    attach: function (context, settings) {
      $(".form-checkboxes").prepend($('&lt;input type="checkbox" class="form-checkbox shield-select-all"/&gt;&lt;label class="option shield-select-all-label"&gt; Select / Deselect all &lt;/label&gt;'));
      $(".shield-select-all").on('click', function () {
        let $isChecked = (!$(this).attr('checked'));
        $(this).parent().find('.form-type-checkbox input[type=checkbox]').attr('checked', $isChecked);
        $(this).attr('checked', $isChecked)
      })
    }
  };

})(jQuery, Drupal);