Yes you can and in fact it is your obligation to do so. The requisites to register state that you should show a residency certificates or if not in possession of that document, a valid passport.
Please note* Translated from the Spanish text:
“All people living in the municipality must be registered on the census whether nationals or foreigners, in the latter case, whether or not their status is regularised in the Register of the Ministry of Interior.”
The town halls do not have the jurisdiction or the right to become involved in matters of legal residency.
Though used in the past as a stepping stone to obtaining legal residence by non EU from some countries, we should take note of the article below:
Article 18 paragraph 2 states that “The registration of foreigners in the municipal census will not constitute proof of legal residence in Spain nor does it confer any rights not granted to them under current legislation, especially concerning the rights and freedoms of foreigners in Spain”