Does the textdomain have to be the theme’s name?

The text domain is a unique identifier, which makes sure WordPress can distinguish between all loaded translations so Using the basename of your plugin/theme is always a good choice because plugin/theme basename is always unique though it is not mandatory to have plugin/theme basename as text domain, you can use any unique identifier.

If you’re translating a plugin or a theme, you’ll need to use a text domain to denote all text belonging to that plugin/theme. This increases portability and plays better with already-existing WordPress tools.

In general, an application may use more than one large logical translatable module and a different MO file accordingly. A domain is a handle of each module, which has a different MO file so you should not use same text domain for different theme/plugin instead it should be unique for every plugin/theme.

You can get more information from this page.