In Sharepoint Online, is it possible to create an alert for when someone shares a file with an external user? Or, if that is too specific, an alert for just using the Share function to share with any user?
You can use the Audit Log in O365 to create alerts on specific event.
Here you find the possible sharing and access request activities: https://docs.microsoft.com/en-us/office365/securitycompliance/search-the-audit-log-in-security-and-compliance#sharing-and-access-request-activities
And here is shown how to create an alert based on those activities: https://docs.microsoft.com/en-us/office365/securitycompliance/create-activity-alerts
Go to https://compliance.microsoft.com and then click Alerts > Alert policies->New alert policy->You can choose the corresponding activity:
For more detailed information, refer to the following articles: