The impulse of a collision is basically the change of velocity from before and after a collision. Using that info you can calculate it. Then you can use lerp or something to map the impulse to a volume.
Here's one possible conversion:
lerp(-1000, 0, min(impulse/1000, 1))
which means when the impulse is 0 the volume will be -1000 dB, and when the impulse is 1000 or higher the volume will be 0 dB. Impulses in between will be between the two volumes. Tweak the numbers for different results.
global number prevVelocityX=0
global number prevVelocityY=0
global number impulse=0
on sprite collides with wall
--- set impulse to distance(0,0, sprite.physics.velocityX-prevVelocityX, sprite.physics.velocityY-prevVelocityY)
--- play sound at volume lerp(-1000, 0, min(impulse/1000, 1))
every tick
--- set prevVelocityX to sprite.physics.velocityX
--- set prevVelocityY to sprite.physics.velocityY