As per my knowledge, yes you can filter JUnit tests by tags or annotations directly from the Gradle CLI without modifying the build.gradle file.
You need to use the --tests option to specify the test class or method. While for JUnit 5, the --include-tags option should work for filtering by tags.
Lokk at this
gradle test --tests * --include-tags "yourTag"
Always make sure that you are using JUnit 5 and the correct Gradle version that supports this functionality.