can we change block title using template_preprocess_block?
See the block_example.module. It's hook_block_view_alter you can use to do this programmatically. You can probably use it in a *.theme as well.

Source block_example_block_view_alter.

use Drupal\Core\Block\BlockPluginInterface;

function MYMODULE_block_view_alter(array &amp;$build, BlockPluginInterface $block) {

  // We'll search for the string 'uppercase'.
  $definition = $block
    -&gt;getPluginDefinition();
  if (!empty($build['#configuration']['label']) &amp;&amp; mb_strpos($build['#configuration']['label'], 'uppercase') || !empty($definition['subject']) &amp;&amp; mb_strpos($definition['subject'], 'uppercase')) {

    // This will uppercase the block title.
    $build['#configuration']['label'] = mb_strtoupper($build['#configuration']['label']);
  }
}




Most often you find answers to questions like that really fast when you google for Drupal X how to X programmatically or similar.