I just faced the same requirement and solved it using withSwiftMessage method by passing the callback function right you're used in your sample. So the Markdown Mailable class' build() method might look like:
public function build() {
return $this->markdown('markdown.view')
->withSwiftMessage(function($message) use (&$message_id) {
$message_id = $message->getId();
});
}