hook_block_build_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block)
Alter the result of \Drupal\Core\Block\BlockBase::build().
Unlike hook_block_view_alter(), this hook is called very early, before the block is being assembled. Therefore, it is early enough to alter the cacheability metadata (change #cache), or to explicitly placeholder the block (set #create_placeholder).
In addition to hook_block_build_alter(), which is called for all blocks, there is hook_block_build_BA