maven-3.9.11 and sonar-maven-plugin:5.1.0.4751 show a warning:
[WARNING] Direct modification of testCompileSourceRoots through iterator.remove() is deprecated and will not work in Maven 4.0.0. Please use the add/remove methods instead. If you're using a plugin that causes this warning, please upgrade to the latest version and report an issue if the warning persists. To disable these warnings, set -Dmaven.project.sourceRoots.warningsDisabled=true on the command line, in the .mvn/maven.config file, or in project POM properties.
and indeed with Maven 4.0.0-rc-3 (3952d00ce65df6753b63a51e86b1f626c55a8df2) and the latest 4.1.0-SNAPSHOT you get an exception (relevant part of the stack trace).
Caused by: java.lang.UnsupportedOperationException
at java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)
at java.util.ImmutableCollections$AbstractImmutableCollection.removeIf(ImmutableCollections.java:152)
at org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.removeTarget(MavenProjectConverter.java:534)
We just released version 5.3 of the scanner that should fix the issue. Would you mind giving it a try and letting us know if you the issue is resolved on your end?