Split the file.txt by colon (:) and assign the output field separator (OFS) to be the same as the input field separator (FS). At the beginning of the command, generate a random number and assign it to the second field. Finally, print the entire line.
awk -F: 'BEGIN {srand(); OFS=FS} {$2=rand(); print $0}' file.txt