How could we achieve the same using Azure Devops task group?
I suggest that you could save the settings.xml file in Pipelines -> Library -> Secure files.
In Task Group, you could add Download secure file task and Maven task.
Download secure file task: Set the Reference Name and select the file
Maven task: Set the reference Settings.xml path: -s $(mvnSettings.secureFilePath)
Then you could create a task group.
Note: You need to set the paramter for the task group:
Default value: $(Agent.TempDirectory)/settings.xml
In this case, the old settings.xml will not be changed. When you reference this task group, it will download the new settings.xml in the secure file and reference the new settings.xml file in the maven task.
If you do not reference this task group, it can still use the old settings.xml file.