You can use MODX tags in the media source path and URL, so I would think something like
/assets/images/[[*template]]/
would do the trick.
As far as automatically generating the directory, I would think a plugin using OnTemplateFormSave (or whatever that one is actually called) would do the job; check if /assets/images/templateID/ exists and is writable, and create it if not.
Be careful with Static Resources, while you can use a Media Source to access the file manager and upload/select a file, the resource itself doesn't recognize media sources, so all you'll get in the path is the part within the media source path.
I work around this by using a chunk with the Media Source path, and prepend this to the Static Resource's path. You can do this with another plugin if you don't want your users to have to remember to prepend the chunk.