Because I did not know any better, I started by reverse-engineering how the Essential theme prints the header image as specified by that theme plugin's configuration setting named "logo". That led me to theme_config::setting_file_url() in moodle/lib/output.lib.
That particular setting_file_url() function does not directly help me with my problem, because I want to get the URL of an image file that is specified by a configuration setting in a local plugin of mine. But, it did give me other crumbs to follow: the moodle_url::make_file_url() and ::make_pluginfile_url() functions in moodle/lib/weblib.php.
I then read the documentation in https://docs.moodle.org/dev/File_API.
I still cannot get what I want to work. But, the above crumbs may help somebody. I know that I have drifted away from the scope of the original post.