If you want to restrict the users to share outside of your organization for all SharePoint site collections and OneDrive. Follow the below steps,
Step 1: Go to Office 365 Admin Centre
Step 2: From the sidebar, expand Settings
Step 3: Click Services & add-ins under Settings
Step 4: From the Services & add-ins page, select Sites. It opens a right side panel
Step 5: Turn Off the Toggle under the External Sharing
Step 6: Click Save button to update the External Sharing settings and then the panel shows the success message.
Step 7: Click Close
After applying this, we won’t be able to share the SharePoint online and OneDrive to external users across all Site Collections and all members within an Organization in Office 365.