Is it possible to write a bash function to change directory by passing the name of a directory variable?

You can use variable indirection:

foo () {
    cd "${!1}"
}

dir=/mnt
foo dir
pwd  # /mnt