Change view title programmatically
You probably want to change the global title used for the title block. This is retrieved from the route. The route for a view is built from the view configuration when you save a view  (or clear the cache). The title in the route is static. If you want to change it, modify it in the view configuration. You can do this in ui or in code.

If you want to make this dynamically, you can replace the static _title in the view route with a title controller _title_callback to provide a different title on every request.