Yes, for this, you will have to use Mailertable.
Please see the link below, and let us know if it suits your requirements:
http://www.sendmail.org/m4/mailertables.html
You might want to add lines like:
.yahoo.com smtp:a.mx.mail.yahoo.com
my.domain esmtp:host.my.domain
Bob