This is not an array. It is a slice. An array would specify the length: array: [42]u8. You can modify the array referenced by the slice: buffer[69] = 'A'. Then you return a new slice: return buffer[0..new_length].
std.fmt.bufPrint is deprecated in favor of std.mem.print. Take a look at the source code of std.mem.print and you might get an idea of how to adapt it to write multiple times: std.mem.print - Zig Documentation (see also std.Io.Writer)