How can I edit a specific FASTQ read in place, given the read ID?
You'll first need to determine the appropriate line number, which you can do with grep -m1 -nw "@31027" foo.fastq. After that, note that you can provide a line number to sed:

sed -i '123456s/CAAAAGTCACTCA/CAAAAGTCACTTA/' foo.fastq


That will do the replacement only on line 123456 and edit the file in place (the -i option).