In Emacs, I can create functions in Lisp language and place them in .emacs
file. Those function will become commands that can be called from the editor or bound
There's Power Tools by e.GO:digital. It has support for custom commands and event triggers (ie. on file changed), among other things.
A few marketplace extensions may be of interest:
However in general, you'll need to write an extension to do anything complex.
There's also a VS Code issue tracking support for built-in macros