You can, but it's not a straightforward setup. The big issue is that your MX record can only point at one email system, so you effectively need a method to distribute messages between Google and M365. Generally speaking, it will be much easier if you use a separate domain (or a subdomain), and an acceptable alternative is to also use the default domain you are given with the service (in the case of Exchange Online, it will be companyname.onmicrosoft.com).
If you do plan to use the same domain in both systems, you need to ensure that users are represented correctly in each system, and that some sort of "forwarding" handles the mail delivery to the correct mailbox. There are some guidelines here: https://video2.skills-academy.com/en-us/microsoft-365/admin/misc/pilot-microsoft-365-from-my-custom-domain?view=o365-worldwide