Your SSH session does not hang, it is waiting for input.
The trick is that you need an interactive shell for the welcome message to be displayed.
You can accomplish that by sending "logout" to an internal ssh session
echo "logout" |ssh server
Then you only need to pipe the output into a file:
user@client:~$ echo "logout" |ssh server > motd.txt
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: No xauth data; using fake authentication data for X11 forwarding.
user@client:~$ cat motd.txt
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-45-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
* Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
https://ubuntu.com/livepatch
0 packages can be updated.
0 updates are security updates.