Hi there,
I’am not able to get sold out message by using plugin also.
In that case, it’s possible something in your theme (template overrides, other code, etc) or in another active plugin on your site might be conflicting with the snippet and preventing it from working.
Testing the second snippet also worked without issue on my test site with just WooCommerce and the default Storefront theme. While the first snippet displayed as shown in the screenshot in my previous reply, the second one displayed like this:
Link to image: https://d.pr/i/LX50TA
To narrow down what is causing it to not work on your site, please temporarily switch your theme back to the default Storefront theme and disable all plugins except for WooCommerce, then check to see if it works. If it does, then switch your theme back and reactivate plugins one-by-one until you find the one that is causing the issue.
You can read about testing for conflicts in our documentation here:
https://docs.woocommerce.com/document/how-to-test-for-conflicts/