After testing(clicking F12 to capture corresponding browser network requests), this request body for this API: Definitions - Update is the same content when you call this API: Definitions - Get to get its definition.
Therefore, you could get the release pipeline definition firstly, and then add below PowerShell task code segment to workflowTasks array, which locates in the result's environments array >>dev stage>>deployPhases array>>workflowTasks array
{
"environment": {},
"taskId": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1",
"version": "2.*",
"name": "PowerShell Script test",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"definitionType": "task",
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"targetType": "inline",
"filePath": "",
"arguments": "",
"script": "# Write your PowerShell commands here.\n\nWrite-Host \"Hello World\"\n",
"errorActionPreference": "stop",
"failOnStderr": "false",
"showWarnings": "false",
"ignoreLASTEXITCODE": "false",
"pwsh": "false",
"workingDirectory": ""
}
}
And then there will an extra PowerShell task in Dev stage.
BTW, each updates will generate a new revision, which is the latest version of release definition, and you need to use the latest version to update release pipeline the next time.