It can be built. It will be deemed as a secondary dwelling.
If you choose to rent it out to two parties independently, if one has a fire in the kitchen and injures the other, understand that insurance will not cover you as how you have rented out the property is illegal.
That said, people do...