Note that a gelatinous cube has "Condition Immunities: Deafened", which either suggests that it can hear, or (possibly) suggests that it cannot hear and therefore cannot be deafened.
One of the design principles of 5e is to not include every rule, and to expect the DM to fill in the details. One example of this that comes to mind is this old question about what happens if a druid wears armor. (The rules just don't tell you, so you have to make something up!) The question of whether monsters have hearing seems similar.
Here are some principles that I follow as a DM, which might be helpful to you:
- Always try to interpret rules in a way that lets characters use their abilities. Players have more fun if their characters can use their abilities; players have less fun if their characters are useless. If someone asks you "hey, can that gelatinous cube hear my vicious mockery?", this suggests that you should answer yes, to allow their character to be useful.
- Try to work with the players' worldbuilding if you can. Players have more fun when you say "yes, and"; they have less fun when you contradict them and say "no, that doesn't work". If your player decides that the gelatinous cube is obviously deaf, or if they decide that goblins are terrified of horses, or if they decide that there's a Thieves' Guild in this town that they can talk to: go along with it, make it part of the story.
- If a character believes something is true, you as DM can't reach into their mind and contradict their belief. If the bard believes Vicious Mockery won't work, then maybe that's true and maybe it's false, but consider letting them believe that. (Especially if they're going to do something creative to work around the "problem".)
I've found that players are happier when I follow the above.
In the case you describe, I would have secretly decided that vicious mockery can work on a gelatinous cube because of magic, but I would've let the bard continue to believe that it wouldn't work as long as they had something different they wanted to try.
If the bard started to feel like none of their abilities was any good, and it looked like they were feeling useless and frustrated, I might offer a hint: "You seem to recall that the magic in your vicious mockery is pretty flexible, and it works on a lot of things. You're not sure if it'll work here, but it might be worth trying just to see..."