You can submit a temporary sitemap with all the hacked URLs to Google as a method for getting Googlebot to come crawl all of them quickly. When you submit a sitemap of URLs, it will trigger Googlebot to crawl the URLs with greater priority.
You want Googlebot to come crawl the URLs so that it sees that they are "404 Not Found." If you don't submit a sitemap with these URLs, it could take Googlebot months to get around to crawling all of the URLs.
Since you have more than 50,000 URLs, you would actually need to submit multiple sitemaps each containing 50,000 URLs. 50,000 is the most URLs allowed in a sitemap. I would not recommend creating a sitemap index file because Google Search Console has had problems with them for the last few years. It typically doesn't show how many URLs it has found in them and it isn't clear that they work properly.
Once Google has seen a sitemap and crawled the URLs in it, you should remove it. I would expect that you should leave each sitemap up for at most a few months.
Reference: Use 404s & Temporary Sitemaps To Speed Up Page Removal From Google Search which quotes Google's John Mueller:
One way to speed this up could be to submit a temporary sitemap file listing these URLs with the last modification date (eg, when you changed them to 404 or added a noindex), so that we know to recrawl & reprocess them. This is something you'd just want to do for a limited time (maybe a few months), and then remove, so that you don't end up in the long run with a sitemap file that's not needed by your site
Submitting a sitemap with tons of 404 errors from hacked URLs won't hurt your site. Again quoting John Mueller
404 errors on invalid URLs do not harm your site’s indexing or ranking in any way. It doesn’t matter if there are 100 or 10 million, they won’t harm your site’s ranking. https://developers.google.com/search/blog/2011/05/do-404s-hurt-my-site
I wouldn't try this technique with other search engines like Bing, Yandex and Baidu. They haven't said that this would be appropriate and I haven't seen any indication that it would work with them.