How can I programmatically extend the registration form?
I had this same question and it doesn't seem to be answered anywhere so I'll give the answer that I figure out, hopefully this helps someone.
First you need to add the form to the entity do this in the module file in hook_entity_type_build something like the following sample:
/**
 * Implements hook_entity_build
 */
function MYMODULE_entity_type_build(array &amp;$entity_types) {

  $entity_types['user']-&gt;setFormClass(
    'MYMODULE_register',
    'Drupal\MYMODULE\Form\myModuleRegisterForm'
  );
}

Create a new class src/Form/myModuleRegisterForm.php to extend RegisterForm:
namespace Drupal\MYMODULE\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\user\RegisterForm;

class myModuleRegisterForm extends RegisterForm {

  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
        
    $form = parent::form($form, $form_state);

    // Change the form here

    return $form;
  }

}

Then load it in your controller
public function myModuleRegister {

  $build = [];

  $entity = \Drupal::entityTypeManager()
    -&gt;getStorage('user')
    -&gt;create([]);

  $formObject = \Drupal::entityTypeManager()
    -&gt;getFormObject('user', 'MYMODULE_register')
    -&gt;setEntity($entity);

   $build['form'] = \Drupal::formBuilder()-&gt;getForm($formObject);

   return $build;
}

That pretty much covers it, obviously you need the route to point to the appropriate function in your controller but otherwise this should do it.  Hope it helps.