Use a twig template instead of a render array in a custom module admin page
The back-end theme automatically switches by path. So if your route's path begins with /admin it will show the page in the admin theme.

MYMODULE.MYPAGE:
  path: '/admin/config/MYPAGE'
  defaults:
    _form: '\Drupal\MYMODULE\Form\MYFORM'
    _title: 'MYTITLE'
  requirements:
    _permission: 'administer site configuration'




To render a form inside your own template you could simply register a new theme implementation inside MYMODULE/MYMODULE.module.

/**
 * Implements hook_theme().
 */
function MYMODULE_theme($existing, $type, $theme, $path) {

  return [
    'MYNAME' =&gt; [
      'render element' =&gt; 'form',
      'template'       =&gt; 'MYTEMPLATE',
    ],
  ];
}


And in the form you set this as the form's #theme.

$form['#theme'] = 'MYNAME';


And in the MYMODULE/templates/MYTEMPLATE.html.tiwg template you print it like so:

&lt;div class="foo bar"&gt;
  {{ form }}
&lt;/div&gt;




Any additional library also can simply be #attached directly to the form.

$form['#attached']['library'][] = 'MYMODULE/MYLIBRARY';




Read More

[drupal.org] Create custom twig templates for custom module.