There are three parts you need to make this work.
1. Your JavaScript, which goes in the Story JavaScript, should look something like:
predisplay['set-return'] = function (taskName) {
if (!tags().includes('menu')) {
State.variables.return = State.passage;
}
};
What you had should have still worked, but it was long out of date.
2. Your link should look like:
<<link "Volver al juego" $return>><</link>>
While <<click>> would have worked, it's been deprecated for a while now. That should not have created a new passage, however, as that form of the macro is not recognized by Twine 2's automatic link parser—which is the reason it's suggested, so Twine 2 doesn't keep creating passages named $return.
3. You must tag each of your menu passages with menu, since that's what the predisplay task triggers on. You didn't mention this step, so I'm guessing you skipped it.