I think you’d want to check the inventory of the variant, then if < a certain number, hide the add to cart button.
This will help to try variables:https://shopify.dev/docs/api/liquid/objects
I would try something like this:
{% if variant.inventory_quantity < 10 %}
Out of stock
{% else %}
Regular add to cart button here
{% endif %}
Try putting that where your add to cart button is (maybe in a snippet like product-form.liquid, you’ll have to read the code in your theme files to see where).
If that doesn’t work, then experiment with other relevant product and variant variables on that page, for example, if you have multiple variants for the product, you might have to cycle through them with a {% for %} loop. You can find all that in the Liquid documentation.
Once you get the code working, then create a CSS class out-of-stock to style it.
Duplicate your live theme first so you can work on a backup theme without affecting the live site.