For SharePoint server, you could set site collection quota to limit site storage to a maximum.
Go to central administration -> Application Management -> Site Collection Quotas and Locks.
For SharePoint online, here are steps:
1.Go to Settings in the SharePoint admin center -> Site storage limits -> Set Manual.
2.Go to Active sites in the SharePoint admin center -> select the site -> Click Storage to open the edit storage limit panel.
https://learn.microsoft.com/en-us/sharepoint/manage-site-collection-storage-limits
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.