Conditionally set ENV var based on hostname

How can I set an ENV var in my Dockerfile based on the hostname? I tried this:

RUN if [ hostname = “foo” ]; then ENV BAR “BAZ”; else ENV BAR “BIFF”; fi

But that failed with

ENV: not found