How to remove block from the page based on cookie value?
I'll assume this is not a block plugin, right (or at least you dont have access to modify it)? If it is or you can modify it, you should add the logic below to your build() method inside your block class.

Is the cookie you're looking for generated from Drupal? Assuming it is, you should be able to do something like this:

HOOK_preprocess_block__myblock__name(&amp;variables) {
  if (!\Drupal::request()-&gt;cookies-&gt;get('mycookie') == 'allow') {
    $variables = [];
  }
  // Don't forget about cache context for cookie!
  $variables['#cache']['contexts'][] = 'cookies:mycookie'
}