Possible to use command-substitution syntax to set variables?

I'm going after good practice when it comes to naming branches. This means I have a branch named development/karlfor example. In GitLab I run jobs that build a docker image. I'd like the docker image to reflect the branch name, however docker does not allow images to include the / character. To get around this i tried to replace the / with a -.

In the .gitlab-ci.yml file I have the following:

variables:
    CONTAINER_NAME: $( echo "$CI_BUILD_REF_NAME" | tr / - )

When echoing the variable it just echos:

$ echo $CONTAINER_NAME
( echo "development/karl" | tr / - )

I was expecting this:

$ echo $CONTAINER_NAME
development-karl

Is there a way to accomplish what I'm looking for?