Golf yourself a beer

Japt, 189 bytes

I almost went insane while trying to get this to work properly...

U?S+'_pC +R:"  oo  o oo\n "+'opC +"\no")+"\\, \\,} |, /,/"q', £(V=(!Y«U?"|: |" +SpA +'|+X,(1+5*Mr)o mZ=>Ul <Y*4+4©(V=Vh2+A*Mr ,'° ),V)qR +"\n \\"+'_pA +'/+R+(Ul ¥3?"Yuck, foam.":Ug22 ?`B¨p:

Try it online!

(Note: This program was made for an older version of Japt, and doesn't currently work in the latest version. To get around this, the older version is specified in the URL. Unfortunately, this also means the top-right code box doesn't work.)

This is by far the longest program I have ever written in Japt. Here's a breakdown:

Step 1: Create the top of the beer mug.

U?S+'_pC +R:"  oo  o oo\n "+'opC +"\no")

           // Implicit: U = input string
           // Begin the ASCII art with:
U?S+       //  If U is not an empty string, a space +
'_pC +R:   //   "_".repeat(12) + a newline.
:"..."+    //  Otherwise, this string +
'opC +     //   "o".repeat(12) +
"\no")     //   a newline and an "o".

If U is an empty string, this makes:

  oo  o oo
 oooooooooooo
o

Otherwise, this makes:

 ____________

Step 2: Create the middle rows of the mug.

+"\\, \\,} |, /,/"q', £(V=(!Y«U?"|: |" +SpA +'|+X,

+"..."    // Add to the previous string: this string,
q', £(    // split at commas, with each item X and its index Y mapped to:
V=(       //  Set variable V to the result of concatenating:
!Y«U?     //   If Y is 0 and U is an empty string,
"|: |"    //    "|"; otherwise, " |";
+SpA      //   10 spaces,
'|+X,     //   "|", and X.

This results in the previous string plus:

 |          |\
 |          | \
 |          |} |
 |          | /
 |          |/

Step 3: Add the bubbles.

(1+5*Mr)o mZ=>Ul <Y*4+4©(V=Vh2+A*Mr ,'° ),V)

            // Note: We're still looping through the five rows at this point.
(1+5*Mr)    // Generate a random integer between 1 and 5.
o           // Create an array of this many integers, starting at 0.
mZ=>        // Map each item Z in this range to:
Ul <Y*4+4©  //  If the length of U is less than Y*4+4,
            //  (in other words, if there's less than Y+1 "sip"s)
(V=Vh   '°  //   Insert "°" at position
2+A*Mr      //    2 + random number between 0 and 9.
),V)qR      // Finally, return V, and join the five rows with newlines.

At this point, the mug looks something like this:

 ____________
 |          |\
 |          | \
 |     °    |} |
 |° °     ° | /
 | °    °   |/

Step 4: Add the final row and optional text.

+"\n \\"+'_pA +'/+R+(Ul ¥3?"Yuck, foam.":Ug22 ?`B¨p:

+"\n \\"    // Add a newline and " \".
+'_pA       // Add 10 "_"s.
+'/+R       // Add a slash and a newline.
+(Ul ¥3?    // If the length of U is 3 (i.e. 1 "sip"),
"..."       //  add the string "Yuck, foam.".
:Ug22 ?     // Otherwise, if U has a character at position 22 (six or more "sip"s),
`B¨p        //  decompress this string ("Burp") and add it.
:           // Otherwise, add nothing.

Now everything is ready to be sent to output, which is done automatically. If you have any questions, feel free to ask!


JavaScript (ES6), 283 281 bytes

s=>` `+(u=`_________`,(s=s&&s.split` `.length)?u+`___
 `:` oo  o oo
 oooooooooooo
o`)+(i=0,l=q=>`|`+[...u].map(_=>Math.random()>.8&i>=s&&b++<5?`°`:` `,b=0,i++).join``+(b|i<s?` `:`°`)+`|`+q+`
 `)`\\`+l` \\`+l`} |`+l` /`+l`/`+`\\`+u+`_/
`+(s&&s<2?`Yuck, foam.`:s>5?`Burp`:``)

Explanation

s=>
  ` `+(u=`_________`,        // u = 9 underscores
  (s=s&&s.split` `.length)   // s = number of sips
    ?u+`_
 `:` oo  o oo
 oooooooooooo
o`)                          // print glass top or foam

  // Print glass lines
  +(i=0,                     // i = line number
    l=q=>                    // l = print glass line
      `|`+[...u].map(_=>     // iterate 9 times
        Math.random()>.8     // should we put a bubble here?
        &i>=s                // has this line already been sipped?
        &&b++<5              // have we already placed 5 bubbles?
          ?`°`:` `,          // if not, place the bubble!
        b=0,                 // reset the number of placed bubbles
        i++                  // increment the line counter
      ).join``               // put the 9 spaces and bubbles together
      +(b|i<s?` `:`°`)       // place a bubble at 10 if none were placed
      +`|`+q+`
 `                           // print the suffix of this glass line
  )`\\`
  +l` \\`
  +l`} |`
  +l` /`
  +l`/`

  +`\\`+u+`_/
`                            // print the bottom of the glass
  +(s&&s<2?`Yuck, foam.`
    :s>5?`Burp`:``)          // print the message

Test

Input: <input type="text" id="sips" /><button onclick="result.innerHTML=(

s=>` `+(u=`_________`,(s=s&&s.split` `.length)?u+`___
 `:` oo  o oo
 oooooooooooo
o`)+(i=0,l=q=>`|`+[...u].map(_=>Math.random()>.8&i>=s&&b++<5?`°`:` `,b=0,i++).join``+(b|i<s?` `:`°`)+`|`+q+`
 `)`\\`+l` \\`+l`} |`+l` /`+l`/`+`\\`+u+`_/
`+(s&&s<2?`Yuck, foam.`:s>5?`Burp`:``)

)(sips.value)">Go</button><pre id="result"></pre>