If you got this error on your Google Search Console and you are positive that the pages shown do not need to be indexed by Google (and other search engines). Follow these steps:

You should have Yoast SEO installed and activated.

Go to the page editor for the pages you would like to remove from the sitemap. Scroll to the Advanced options on the Yoast SEO block and set the "Allow search engines to show this Page in search engines?" to No.

Save your work and check your sitemap. Now go to your Google Search Console profile and select the 'Validate Fix' option.