Hello,
Thank you for your question.
If you are going to use some web applications of other companies then Federation is best way and you may need to do some complex configuration in ADFS server and Firewalls proxy.
But If you are going to use File sharing resources or Authentication with other company's Servers or Computer then AD Trust will be best way and its easy configure. all you need to do is to set up VPN between two companies and open AD ports,
Regarding SMB ransomware you could tighten your security from Firewall and using Antivirus or security software.
Hope this helps.
--If the reply is helpful, please Upvote and Accept as answer--