No, namespace is not mandatory while creating custom module.
In Magento, using namespaces is not mandatory when creating a custom module, but it is highly recommended. Namespaces help in organizing code, preventing conflicts with other modules, and improving code readability. By using namespaces, you can avoid naming collisions with other modules or classes within the Magento system.
Therefore, while it’s not strictly required, adhering to best practices by utilizing namespaces in your custom module development is strongly encouraged for maintaining a well-structured and scalable Magento application.