This is solved using inspiration from https://stackoverflow.com/questions/28001878/git-fetch-unshallow-gives-fatal-unshallow-on-a-complete-repository-does-n
For Azure DevOps Build Pipelines, you need to go to the build pipelines => Edit => Triggers => YAML => Get sources
Then tick Shallow Fetch and set the depth to 2147483647 as noted by https://stackoverflow.com/a/46477285/780866
Once all this is done, re-run the pipeline and the warning in SonarQube will go away