While playing the game press the forward-slash key (/) and a small window will pop up. Enter the code, press enter and this will be enough to have your command activated.
Use this command to play a specific sound file. For example, it can be used to have a soft sound a doorbell every time someone opens a door. You can find all the sound file names here.
For instance: /playsound minecraft:entity.elder_guardian.ambient voice @a