It's straightforward, but can be a bit cumbersome if you've not built Chromium before. I'd suggest reading the headless_shell markdown notes, and to take a look at the build script used by the chromedo docker repo here:
https://github.com/chromedp/docker-headless-shell/blob/master/build-headless-shell.sh
The script might not be usable for you out of the box, but should give a clear, 10,000 meter view on the steps needed to build (and customize) headless_shell.
(Note: ignore the instructions/comments in the script about icecc, as the icecc-chromium scripts recently broke, and as far as I am aware, still do not work with latest chromium tagged versions)
Long/short of it is that one should follow the general steps to checkout/update Chromium, and then setup a project file (
args.gn) that includes the
headless.gn config/args. Then, after running gn gen, use ninja to build the headless_shell and chrome_sandbox targets.