There were plenty of Macintosh viruses that spread this way, such as the WDEF/MDEF/CDEF families.
> Infects the Desktop file used by the Finder. … Spread through sharing disks, as every Mac disk includes a Desktop file. It is not necessary to run a program to spread this virus; simply mounting the disk is enough for it to infect the Desktop file of every disk mounted on the Mac.
> Infects the Desktop file used by the Finder. … Spread through sharing disks, as every Mac disk includes a Desktop file. It is not necessary to run a program to spread this virus; simply mounting the disk is enough for it to infect the Desktop file of every disk mounted on the Mac.
https://lowendmac.com/2015/classic-mac-os-viruses/