It is possible to create own Linux distribution using Yocto Project.
For Raspberry Pi- there is a specific layer meta-raspberrypi that needs to be used to create an image.