Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.
Unfortunately, we do not have a dynamic way of setting the no-index option when your products are out of stock.
However, in Rank Math PRO you can noindex hidden products, assuming they are out of stock:

This option will help your products be set to noindex and hence not be included in the sitemap. The noindex for hidden products option does apply if you do not want the hidden product page to be included in SERPs.
Here’s a link for more information:
https://rankmath.com/kb/general-settings/#noindex-hidden-products
I hope that helps.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.