Change system mail on run time when sending mail
You can alter the mail using hook_mail_alter(&amp;$message)


  Alter an email message created with MailManagerInterface->mail().


with in message array you have 'from' field as well.

Example

function mymodule_mail_alter(&amp;$message) {
  if ($message['id'] == 'modulename_messagekey') {
    // Login to get domain specific email id.
    $email_id == _some_logic_to_get_email();
    $message['from'] = $email_id;
  }
}


Refernce: https://api.drupal.org/api/drupal/core%21core.api.php/function/hook_mail_alter/8.2.x