Use CKEditor on textarea in custom module's controller response
I'd imagine you just return the same element you'd build into a form, and use a format that's configured to use a WYSIWYG:

return [
  '#attached' =&gt; ...,
  '#type' =&gt; 'text_format',
  '#title' =&gt; 'Foo',
  '#format' =&gt; 'full_html', 
];


See the TextFormat class for more options.