How can I can I add functionality to my module so that the templates can be overwritten? How can I can I add functionality to my module so that the templates can be overwrittable like in drupal core. I want to be able to use my module with various themes, but change the required templates.

The only way I have seen to add is via drupal_get_path and explicitly specifiying a theme/module.
You need to declare your templates by implementing hook_theme(), and when needing them in your module uses a render array rendered with the RendererInterface::render() method on the renderer service.

Theme, or other modules, will then be able to declare override for your templates like they do for any others.

The theme system overview in Drupal documentation gives more details on this process.