How to override a setting in appsettings.json with one in docker-compile.yml?

I have a setting “MyCustomKey” in the appsettings.json file in an ASP.NET Core project:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "MyConnStr": "Password=..."
  },
  "MyCustomKey": "MyCustomKey Value coming from appsettings.json"
}

I would like to override it in the docker-compose.yml or docker-compose.override.yml file, so that

  1. No code change is needed in the web app
  2. If the overriding setting in the YML file is present, the YML setting will be used.
  3. If the YML setting is not present, the setting in appsettings.json will be used.

How do I do it? I know how to do it on the connection string, but I don’t know how to do it on an arbitrary app setting.