The ternary operator may be used for assigning directly a value to a key of an associative array, but it is not possible to generate the key name itself by this way !
For such a scenario, it is better to append (or not) a key=>value as a whole, to the array, if a condition is true. Of course, that condition can be evaluated with a ternary operator.