I was able to get this to work using a 2013 iMac in Target Display Mode. The 2013 iMac was connected to a 2011 iMac by a Thunderbolt cable. I needed to make sure muting was not checked off and the volume was up high enough on both the 2011 and 2012 iMacs. I was able to access the System Preferences on the 2013 iMac by using Screen Sharing.
Below is a image of the 2013 iMac screen while the 2013 iMac is in Target Display Mode. The System Preferences window is shown for both the 2011 iMac and the 2013 iMac. The 2013 iMac System Preferences window is on the desktop of the 2013 iMac. The 2013 iMac desktop is being accessed through Screen Sharing.
Note: The 2013 iMac has both High Sierra and Catalina installed. The sound and display both work when booted to High Sierra and in Target Display Mode, but only the Display works when booted to Catalina and in Target Display Mode.