Your App would listen to 2 webhooks. One for when the product is created to assign the tag(s). The second would be for paid orders. Since orders contain line items that are products (a variant), you can easily scan for sold out inventory and then change the parent's tagging. You could also trigger any kind of sync with a button as this App would be embedded in your Shop.
- difficulty level: easy
- time consuming: no
- expensive: no