${__urlencode(osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY)}
if you prefer to use the code you're shared you can go for __groovy() function like:
${__groovy(URLEncoder.encode("osi5oX-:?0A3YiG4aCpZ.Y[+PW51pZVY"\, "UTF-8" ),)}
however it uses more or less the same code under the hood hence will produce the same output: