I had to play audio recently in a Shiny app, but it also works in RMarkdown. It uses the audio element linked by @jcblum above. I think its easier to play audio in a browser than looking for a way to play audio on all systems.
The pertinent code, adapted from here:
audio_player <- function(audio = "output.wav",
html = "player.html"){
writeLines(sprintf('<html><body>
<audio controls autoplay>
<source src="%s">
</audio>
</body></html>',
audio),
html)
utils::browseURL(html)
}
Watch out for browser caching, as it will not update the audio file if you change it, to get around that I call the audio file a different name each iteration.