How can I exclude certain products in Magento 2 from generating Magento sitemap.xml?

I have found a similar solution for this (excluding certain products from the Magento Sitemap.xml generation) for the version smaller than Magento 2.0, I wanted a solution in Magento 2