Add external CSS file with custom backend setting
hook_library_info_build() would be the right hook to add dynamic library definitions (definitions that depend on any run-time information) but it needs to be implemented by a module, as its documentation page says.


  Modules may implement this hook to add dynamic library definitions. Static libraries, which do not depend on any runtime information, should be declared in a modulename.libraries.yml file instead.


hook_library_info_alter() can be implemented by either a module or a theme.


  Allows modules and themes to change libraries' definitions; mostly used to update a library to a newer version, while ensuring backward compatibility. In general, such manipulations should only be done to extend the library's functionality in a backward-compatible way, to avoid breaking other modules and themes that may be using the library.


If there are default values you can use (for example, using a local CSS file that is then replaced from hook_library_info_alter() basing on run-time information), you can put those default values in the .libraries.yml file, and use hook_library_info_alter() to alter them.