Nevermind, I figured it out:
using Symbolics
@variables x[1:2] y[1:2]
function f!(result, arg)
result[1] = arg[1] + 2
result[2] = 2 * arg[2] + arg[1]
nothing
end
yy = collect(y)
f!(yy, x)
This gives
julia> yy
2-element Vector{Num}:
2 + x[1]
x[1] + 2x[2]