You do not need to register your company with the Brønnøysund Register Centre until after your application for a first-time residence permit as a sole proprietor has been approved.
If you already live in Norway, you can register the company before applying. However, you cannot start working unless you have a residence permit that allows self-employment. Registering a company alone is not sufficient – you also need the correct residence permit.