Try this. It seems to need to be surrounded in double quotes.
echo $(curl -s "https://teams.microsoft.com/downloads/DesktopUrl?env=production&plat=osx&arch=64")
The above produces this for me:
https://statics.teams.microsoft.com/production-osx/1.0.00.14454/Teams_osx.dmg
I can then curl against that to get info on size and other details, or just download it
curl -sI https://statics.teams.microsoft.com/production-osx/1.0.00.14454/Teams_osx.dmg
Putting some of the above together with a few other items
#!/bin/sh
TeamsURL="https://teams.microsoft.com/downloads/DesktopUrl?env=production&plat=osx&arch=64"
## Get the actual download URL
DownloadURL=$(curl -s "$TeamsURL")
## Extract the DMG Name from the path
DMGName="${DownloadURL##*/}"
## Download the DMG into /tmp/
curl -s "$DownloadURL" -o "/tmp/$DMGName"
I'll leave the rest to you to work out how to mount it and install it if that's what you were looking to do.
Now I just feel stupid. Thanks.
Don't forget to check package and app signatures.