#JavaScript (ES6), 78 bytes

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

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

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

[Try it online!](https://tio.run/##FYtBDoIwEADvvGIPJrQpFC9GAxRe4A9MalMKKrhLCvGCvL3W08xh5mU@ZrH@Oa85UudC6BXDjNRda53owzYq3KNofZfezZOxjhW6GDKrmqtZH9Ib7OjNeC1PbZ6P33NpOVfN2PYMeUmhJ88QFBwrQKgVXCKF4LAlAJZwocnJiYbYCEjLG6aR/1Wk0XmV7OEH "JavaScript (Node.js) – Try It Online")

###Commented

    f = (                         // f = recursive function
      n,                          // n = input
      o = `___\n_${k = n}_\n___`  // o = minesweeper field / k = backup of n
        .replace(/_/g, c =>       // for each underscore character c in o:
          Math.random() < .5 ?    //   random action:
            --k | 7               //     either decrement k and yield 7
          :                       //   or:
            c                     //     let the underscore unchanged
        )                         // end of replace()
    ) =>                          //
      k ?                         // if k is not equal to 0:
        f(n)                      //   try again
      :                           // else:
        o                         //   stop recursion and return o