Custom Boards With Custom Programmed Microcontroller
Usually, microcontrollers are programmed at manufacture. You supply the binary files to the assembly company and they'll flash the chips.

Some chip vendors will ship you chips pre-programmed with your image for a fee. This is likely only cost effective once you are ordering 1000s of units.

See also:
Pre-programming surface mount ICs