I am not a user of the shell script scm plugin, so it may be that I'm not understanding how you see the failure or the details of the failure. I assumed that you chose shell script scm plugin in this bug report accidentally and are instead using an "execute shell" step in a freestyle project. When I enter that text into a freestyle project definition using the "Execute shell" step, it saves without any issue. The resulting job runs as expected and reports "HelloWorld" as expected.
Can you provide the stack trace that is written to the Jenkins log file when the failure happens?
Can you provide the list of plugins and their versions as generated by the system groovy script in "How to report an issue"?
Can you provide a more detailed description of the location where you enter that text?
Workaround solution: Remove "cd ${WORKSPACE}" before EOF.
cat > HelloWorld.sh <<- 'EOF'
#!/bin/bash
echo HelloWorld
EOF
#!/bin/bash
echo HelloWorld
EOF