==>You can get the current product category using the below code.
NOTE: Please do not use the Object manager
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Block\Product\View')->getProduct();
$categoryId = $product->getCategoryId();
echo $categoryId;
?>
==>And now get the array of the selected category from your backend and write the login as per the below code.
<?php
$selectedCategory = [2,3,5];
if (!in_array($categoryId , $selectedCategory))
# code...
#Add To Quote
}
?>
I hope this is helpful to you!!