Install prerequisites
brew install pkg-config autoconf automake libtool nasm
Download latest source from https://github.com/mozilla/mozjpeg/releases/latest
cd <source_code>
autoreconf -fiv
./configure
make
N.B. All of this can also be found in https://github.com/mozilla/mozjpeg/blob/master/BUILDING.txt
Or, if you just need the binary, just
brew install mozjpeg
...