interactive tooltips are a wip, but to the larger point, D2 has a plugin system which enables extensions like this (https://github.com/terrastruct/d2/pull/91). there's still some fleshing out to do with the API, but once it's up, it should be a straightforward plugin for custom handlers.
made an issue to track: https://github.com/terrastruct/d2/issues/134