You can create separate profiles one with sound disabled (default) and one with sound enabled. These are available both in Terminal and iTerm2.

<b>Terminal</b>
[![enter image description here][1]][1]


<b>iTerm2</b>

[![enter image description here][2]][2]


  [1]: https://i.sstatic.net/XAd8b.png
  [2]: https://i.sstatic.net/M6EYl.png