Based on the error message, it seems that this issue comes from a script format or symbol.
I have tested the YAML sample from the link you shared and it can work fine.
Here are my steps, you can refer to them.
Step1 : Set the variable CHROMATIC_PROJECT_TOKEN

Step2: Run the YAML sample:
stages:
- stage: Test
displayName: Chromatic Testing
# Job list
jobs:
- job: Chromatic_Deploy
displayName: Install packages and publishes to Chromatic
steps:
- task: NodeTool@0
inputs:
versionSpec: '12.x'
displayName: 'Install Node.js'
- task: Npm@1
inputs:
command: 'install'
workingDir: '$(build.sourcesdirectory)'
- task: CmdLine@2
displayName: Publish to Chromatic
inputs:
script: npx chromatic --project-token=${CHROMATIC_PROJECT_TOKEN}
Here is my result:

You can also try to use --project-token=$(CHROMATIC_PROJECT_TOKEN)
in the YAML sample.