Here is a quick demo of using margins on soft bodies.
Default margin https://www.babylonjs-playground.com/#8WC6ZN#8
Margin set to tube radius https://www.babylonjs-playground.com/#8WC6ZN#9
After doing the demos I realised that I knew about setting margins with soft bodies but not how to do it on rigid bodies and generally knew only a little about what is available with Ammo.js. I thought it might be useful to show how to find out about native functions. As I have been working with Ammo recently I will restrict my observations to Ammo.js but the principals apply to the other two as well.
A margin is set using (would you believe it) setMargin so let’s look at setMargin by going to Bullet Collision Detection & Physics Library: Class Members (since Ammo is built from Bullet this is the best place, I have found, for checking out Ammo stuff). Jump to the ‘s’ page and do a ‘Find in This Page’ search for setMargin
This lists all the members to setMargin applies to. How do we find where and when to apply it? Wel we can see that it applies to a box shape so create a box.physicsImpostor and use console.log(box.physicsImpostor.physicsBody)
https://www.babylonjs-playground.com/#YUNAST#14
In the console (for AmmoJSPlugin) you get an object with a ref number that you click on
to bring up the prototype list
which can expand to give a list of properties and functions that apply to a physicsBody.
scroll down this list to see what is available and you come across getCollisionShape
which was one object setMargin applied to
add this function to your logger
console.log(box.physicsImpostor.physicsBody.getCollisionShape()) and check the console and expand the results to find

So to set the margin on a box.impostor use
box.physicsImpostor.physicsBody.getCollisionShape()
The next question is does it do anything.
Not if both are rigid bodies
https://www.babylonjs-playground.com/#YUNAST#15
so make the box a soft body https://www.babylonjs-playground.com/#YUNAST#16
add margin to soft box https://www.babylonjs-playground.com/#YUNAST#17
and then adding a margin to the ground as well does affect the distance between them https://www.babylonjs-playground.com/#YUNAST#18
A margin just on the rigid body does not affect distance https://www.babylonjs-playground.com/#YUNAST#19
Further experimentation seems to show that the two margins (soft and rigid) have to be the same number for both to have a reasonable affect.