I don’t see how a familiar hiding in a pocket is doing anything beneficial in the fight but maybe there’s more to it than you’ve described.
Personally, I’d allow the familiar to hide if it made sense that it could do so, taking size and other factors into account. But to be useful and give the Rogue advantage, the familiar needs to use the Help action.
Alternatively, you can aid a friendly creature in attacking a creature within 5 feet of you. You feint, distract the target, or in some other way team up to make your ally’s Attack more effective. If your ally attacks the target before your next turn, the first Attack roll is made with advantage.
The familiar would have to make itself at least visible for this to happen and from that point I’d rule it can be attacked, either directly on the Goblin’s turn or by holding an Attack action until the familiar next tried to Help.
I would rule against a player getting continual, never-ending advantage because a familiar was hiding on them and never being exposed to danger. It isn’t game breaking but it is quite strong.
A very good comment was asked about creatures sharing the same space, which I didn’t mention at all so I’m adding it now.
This is a personal ruling for how I’d handle it. I have no issue with a tiny creature hiding on a medium sized player, a rat fitting in a pocket kinda thing, but for the Help action to be done the familiar would have to move into an adjacent square, perform its distraction and move back. This is to allow for targeting the familiar in the simplest way. It’s really just a mechanical description for something that could just as easily be ignored.