Hi,
Yes Defender for Office 365 is designed to do this. In majority of scenarios (on-premise, Cloud, Hybrid, and any other SMTP solution).
The only technical perquisite is to register MX record points to Exchange Online Protection (EOP)
See Here
https://learn.microsoft.com/en-us/exchange/transport-routing
For features and licencing, check here (example: Safe Documents is available only in A5/E5/F5/G5 Security licences)
I hope this helped.
If the answer is helpful, please click "Accept Answer" and kindly upvote it.