Assuming that the those Z-prefixed strings you shared are from the id attribute of aws_route53_zone, you could generate a string like that with an expression like this:
join(",", [for z in aws_route53_zone.private : z.id])
This expression has two main parts:
The [for ... in ... : ...] is a for expression, used for constructing one collection from another. In this case it visits each element of aws_route53_zone.private – which is a map of aws_route53_zone objects – and takes its id attribute, collecting all of the results into a list (due to the [ ] brackets).
The join function takes a list of strings and concatenates all of the elements of that list together using a given delimiter, which in this case is ",".
The result should be a string like the one you included in your question. You can place this expression anywhere that Terraform expects an expression returning a string.