Theming custom block in twig file and render variables
You probably just need to define the available variables:

function my_module_theme() {
  return [
    'custom_block' =&gt; [
      'template' =&gt; 'custom-block',
      'variables' =&gt; ['my_variable' =&gt; ''],
    ],

  ];
}


You'll need to rebuild caches for the change to be picked up.