How do I get a textarea form field to use a full HTML WYSIWYG editor? I have configuration form for a custom module.

namespace Drupal\amu_http_status_code_display\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

class AmuHttpStatusCodeDisplayConfigForm extends ConfigFormBase {

  public function getFormId() {
    return 'AmuHttpStatusCodeDisplayConfigForm';
  }


  public function buildForm(array $form, FormStateInterface $form_state) {

    $config = $this-&gt;config('amustatuscode.settings');  
    $form = parent::buildForm($form, $form_state);

    $form['404_message'] = array(
      '#type' =&gt; 'textarea',
      '#title' =&gt; t('404 error message'),
      '#description' =&gt; t('error 404 message.'),
      '#default_value' =&gt; '404 error',
    );

    $form['403_message'] = array(
      '#type' =&gt; 'textarea',
      '#title' =&gt; t('403 error message'),
      '#description' =&gt; t('error 403 message.'),
      '#default_value' =&gt; '403 error',
    );

    return $form;
  }

  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    $config = $this-&gt;config('amustatuscode.settings');
    $config-&gt;set('404_message', $form_state-&gt;getValue('404_message'));
    $config-&gt;set('403_message', $form_state-&gt;getValue('403_message'));
    $config-&gt;save();

    return parent::submitForm($form, $form_state);
  }

  public function getEditableConfigNames() {
    return ['amustatuscode.settings'];
  }

}


How can I make the form field I add use a WYSIWYG editor?
You want to use the TextFormat form element: https://api.drupal.org/api/drupal/core%21modules%21filter%21src%21Element%21TextFormat.php/class/TextFormat/8.4.x

Note that this will give you a value and a format in a nested form structure, you need to store both (or lock to a specific format) and then render the content with that format to avoid security issues.