#JavaScript (ES6), 80 bytes

Empty slots are `_`, mines are `7`.

<!-- language-all: lang-javascript -->

    f=(n,k=n,o=`___
    _${n}_
    ___`.replace(/_/g,c=>Math.random()<.5?--k|7:c))=>k?f(n):o

[Try it online!](https://tio.run/##FctBDoIwEIXhPaeYhQltCsWN0QCFE3gDk9qUggrOkELcIGevdfX9i/de5mMW65/zmiN1LoReMcxGhRmpu9Y60YcN94jWd@ndPBnrWKGLIbOquZr1Ib3Bjt6M1/LU5vn4PZeWc9WMbc@QlxR68gxBwbEChFrBJSoEhy0BsIQLTU5ONMSNgLS8YRr9X0Uam1fJHn4 "JavaScript (Node.js) – Try It Online")