Set a random user password

virt-sysprep --operations 'customize' --password user1:random \
-a /var/lib/libvirt/images/test.qcow2

If user is present it will produce an output

virt-sysprep: Setting random password of user1 to PASSWORD

Set a random root password

virt-sysprep --operations 'customize' --root-password random \
-a /var/lib/libvirt/images/test.qcow2