YAML multi line scalars in JSON.stringify with TypeScript

I have a YAML document I’m trying to convert to Pulumi which makes liberal use of multi-line scalar values. Here’s an example:

apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: azure-secrets
spec:
  provider: azure
  parameters:
    usePodIdentity: "false"
    keyvaultName: "kvname"
    cloudName: ""
    objects:  |
      array:
        - |
          objectName: secret1
          objectType: secret                    # object types: secret, key or cert
    tenantId: "tid"

Note the usage of scalars and a nested yaml pattern for the objects key.

I’m currently manually constructing this pattern like so:

objects: `array:n  - |n    objectName: $CERT_NAMEn    objectType: secretn`,

Which will manually build the correct YAML format, but I’d like to use JSON.stringify to construct this instead so I don’t have to manually build the strings. Is there a way to do it?