Arduino is just a fancy HAL that hobbyists like to use. So yeah nothing about it prevent you writting kernel.
In fact, the arduino port on esp32 is just a task of FreeRTOS, a multitasking kernel.