Many functions use Arrays as arguments so your question is really how do you construct an Array
?
If you have a variable as a key then it’s better to set it using square bracket syntax.
// key pairs in array constructor
$args = array(
'key' => 'value',
);
// key pairs outside of array constructor
$key = "This is my key";
$value = "This is my value";
$args [ $key ] = $value;
// pass your array now
do_action ( 'xyz', $args );