It seems that the error is coming from Office 365 change were TLS 1.0 is being superseded by TLS 1.2. Since it's still working for my default configuration, I guess my tenant is not yet forced on TLS 1.2, but others already switched. The fix is simple. Before executing Invoke-RestMethod, just run this:
This change stays active for the whole PowerShell session. If you close and reopen PowerShell, it will be gone. If you use Invoke-RestMethod in your scripts, add it in a function next to the first Invoke-RestMethod you use. If you want this always to be available – add it to your PowerShell profile. That way, you won't have to worry about it. Just remember to tell others if you send the scripts over. Keep in mind, however, that this change may impact other commands that you use. If you work with some legacy systems that don't support TLS 1.2, you may need to work it out before going full-on TLS 1.2. If you want to read more about the change, you can read about it Preparing for TLS 1.2 in Office 365 and Office 365 GCC. While in theory they will start turning off TLS 1.0 and TLS 1.1 as of June 2020, it seems some tenants and some services got the change a bit earlier.