Albeit not pretty, I'd replace the square brackets with chars that "may" not be part of a nickname (e.g. round brackets) - and translate these chars back, if needed.
Unfortunately, you cannot use quotes or escapes, $encode won't help either. Of course, there may be networks that extended the "common" set of chars allowed for nicks ( letters, digits, []{}_-|^`\ )...