Indeed, that replaces the content of the variable, but not the name.
I have a variable in a JSON file named container-title. I cannot display this variable with {{ .container-title }} because it throws the error. replaceRE or urlize only work with the output of the variable, not the name.
In other languages, I can escape the dash by, for example, using quotation marks. Does Hugo have a similar option?
That makes little sense. JavaScript (and by extension JSON) does not allow dashes in variable names: JavaScript.com | Variables
So what does your JSON really look like?
This (container-title) is not a variable name. It is the name of a property. Also, your error description is lacking a bit. Apparently, the problem does not when you read the JSON file but when you try to access the property (which has been converted to a key in a map by Hugo when it read the file). Obviously, a dash in a variable name is not allowed in Hugo.
However, index . "container-title" might give you what you want, provided that . contains the map.