welcome to Switzerland!
These are two separate issues: rental and registration.
In short: on no account, ever, should you rent somewhere (even just one room in a flat-share) in Switzerland according to an "informal arrangement". On no account should you or anyone else "pretend" do live somewhere, in the stead of someone else. Please don't do it! It just leads to confusion, and can turn out to be very, very expensive to solve if ever anything goes wrong. The sublet contract (between you and your friend) should be formalised and it really, really is best to get it all done properly, in writing, signed and approved by the landlord.
For info about rental and, more particularly the hows and whys of subletting (which is what you would be doing by moving in to the flat when someone else holds the main rental contract), please have a look at this thread: Subletting via airbnb - legal issues?
Although it starts off being about airbnb, it soon goes on to be about the rules for subletting (since airbnb is considered a kind of sublet).
Yes, all residents of Switzerland (even Swiss people!) have to register. This is done at the municipal offices / town hall and is compulsory within 8 days of arrival. We (and you) all have to state where we reside, and sometimes, to document it with a rental contract.
In at least some municipalities, there is a reciprocal responsibility between the town hall and the landlords, so that a landlord will be informed by the municipality when someone registers at the address of his/her building, and vice versa.
This may sound like Big Brother to you, coming, as you do, from a different system. Here, however, it is completely usual. For foreigners, the date of registration also becomes relevant for renewal of residence and work permits.
These two issues, rental and registration, must rank amongst the two most common areas (along with, e.g. drivers' licences) in which new immigrants to Switzerland inadvertently cause themselves problems, later. I hope you get them right (= formalised, signed on paper).