Well, the sanitization would look like this:
Discourse.Markdown.whiteListTag('script', 'type', 'text/javascript');
Discourse.Markdown.whiteListTag('script', 'src', /https:\/\/asciinema.org\/a\/\d+.js/);
Discourse.Markdown.whiteListTag('script', 'async');
Then you just need to write Ruby onebox code to generate that script tag.