|Absolutely YES, you can design and set up an operating system literally by scratch. All you need is knowledge of the assembly language related to the processor you choose as platform (e.g. IAX86 or X64).|
You have to plan and design the basic components almost the Loader, the Kernel and its File System and the minimum set of device drivers. This is a well known lab exercise exploited at College for Computer Science classes.
If you want to walk through a "simple" kernel take a look at FreeDOS, the Open Source DOS clone, where you can find the source codes for all DOS components.