You could use JSON variable substitution. This feature substitutes values in the JSON configuration files. It overrides the values in the specified JSON configuration files (for example, appsettings.json) with the values matching names of release pipeline and stage variables.
When in "Deploy Azure App Service" release task you should see a "File Transforms and Variable Substitution" section. In here you will supply the path to the json file you want to swap variable values.
[![enter image description here][1]][1]
Then you just need to define the required substitution values in release pipeline or stage variables. From here you can add the json property you want to modify as a variable.
[![enter image description here][2]][2]
Finally after the transformation, the JSON will contain new. Azure DevOps will then swap out these values for you when deploying.
More details you could refer our official tutorial here: [File transforms and variable substitution reference][3]
Update:
It only works to adjust existing entries in the appsettings.json files, it doesn't seem to be able to add any new one. You could also take a look at the JSON variable substitution notes
Variable substitution is applied for only the JSON keys predefined in
the object hierarchy. It does not create new keys.
As a workaround, you could choose to use the File Creator extension:https://marketplace.visualstudio.com/items?itemName=eliostruyf.build-task to push the whole new appsettings.json file in the pipeline.
Update2
OP finally moved with PS script written by him to add new elements in Arrays of Appsettings.json