Please follow the following steps.
1- Go to the Products section.
2- Click on the expand icon
3- Click on the settings.
4- Enter the overall quantity limit.
That will be the overall quantity set for the product/variant and after that quantity is exceeded it will show sold-out button.