The documentation shows a sample configuration for migrating queries (TfsSharedQueryProcessorOptions) that includes SourceName and TargetName parameters. My original problem was that when trying to use the config sample to migrate queries, I was getting and error messages saying: "There is no endpoint named [sourceName]".
Things I tried: I changed endpoint names for the existing Endpoints node, I added a new child Endpoints node inside TfsSharedQueryProcessorOptions, I changed the name TfsEndpoints to TfSharedQueryEndpoints, etc. But none of that worked. I eventually found a way to make it work. Please see my own answer below.
Eventually, I found a way to make it work. So I thought I'd share my config, in case someone else is stuck on this. In the config below, change the parameters Version, Organisation and Project to your own values. Also change the AccessToken parameter if you set AuthenticationMode to "AccessToken". This is my entire config to migrate queries: