Inline conditional for variable's existence

I want to use the cond function to assign a value to a variable. The condition for the assignment depends on whether a particular param variable exists or not.
Could someone help me with this?

{{ $variable2 := (cond ($.Param "variable1") "true value" "false value") }}

This fails because $.Param "variable1" isn’t a conditional expression. Is there a way to turn it into an inline conditional expression.
I’ve also tried using if and nesting the conditionals but for some reason, I can’t overwrite the values of the variable.

{{ $variable2 := "some value"  /*Initializing necessary for Hugo*/ }}
{{ if ($.Params "variable1") }}
  {{ $variable2 := "true value" }}
{{ else }}
  {{ $variable2 := "false value" }}
{{ end }}

Why does this simple code snippet fail? Please help me with both of these snippets.

As .Param will return nil when none found, I guess you can do:

{{ $variable2 := (cond (ne ($.Param "variable1") nil) "true value" "false value") }}

For your second question. If you have Hugo 0.48:

{{ $variable2 := "some value"  /*Initializing necessary for Hugo*/ }}
{{ if ($.Params "variable1") }}
  {{ $variable2 = "true value" }}
{{ else }}
  {{ $variable2 = "false value" }}
{{ end }}

For earlier Hugo version, see Scratch.

@bep Thanks.