How to invoke a custom callback function in Javascript
For very basic Commands, you likely do not need to implement CommandWithAttachedAssetsInterface or CommandWithAttachedAssetsTrait.

Here is a good blog post tutorial for a custom Command: https://www.mike-miles.com/blog/creating-ajax-callback-commands-drupal-8

Here is another example: https://www.mediacurrent.com/blog/loading-and-rendering-modal-forms-drupal-8

Here are a couple modules that implement Commands for an example:


iGrowl
SweetAlert


You are not going to want to override core Drupal JS, as it is easy to add your own and communicate to your plugins or third party plugins as demonstrated above.