It isn't valid YAML to have a repeated key. E.g., the following is not valid YAML:
fruits: foo
fruits: bar
If your YAML file starts with:
fruits: whatever
bar: baz
then there is no way to modify the value associated with the key fruits
by appending to the file. Different YAML parsers may interpret repeated keys in their own way, but the spec defines it as an error.
You could post-process a YAML file, if you want, e.g.:
fruits1: whatever
bar: baz
fruits2: something else
and then in your code, just merge them values associated with fruits1
and fruits2
(and fruits3
, ...) however you like.