In the Go text/template
language, pipelines and function calls are equivalent and you can freely substitute in either direction
{{ x | f a b }}
{{ f a b (x) }}
You can't distribute a parameter across multiple functions as you're suggesting here; you need to repeat it (or put it into a local variable). Looking through the catalog of Sprig functions, I'm not sure there's any specific function that matches your needs that would make this simpler. You have to spell it out:
demo: {{ not (and (contains "demo" .Values.global.api) (contains "prod" .Values.global.api)) }}
As I parenthetically suggested, you can use a local variable to shorten this a little:
{{- $api := .Values.global.api }}
api: {{ quote $api }}
demo: {{ not (and (contains "demo" $api) (contains "prod" $api)) }}