It depends on the country and if the school is public or private. If the teacher is considered an employee and does that then he can be charged for abandoning work or breaking his contract of services with the school if the entire class goes to complain to the school administration, in which case the teacher could even be fired. BUT on the vast majority of situations... yes, he can. To answer the questions:
1-Would he be able or be allowed to not teaching, let us handle it ourselves and only come to do the test?
R- Yes. However petty and childish that is he can and would. Of course he should be reported, but best the student can do is ask another teacher of the same subject/class to allow you as listener (just to enter class and hear the lecture). Modern times do require modern solutions too, so making a scandal in social media might help. On the other hand, it could be argued that he was teaching you all a lesson.
2-Would he be able to fail the whole class?
R- Yes. He can, or fail someone he doesnt like. In which case the whole class or the affected ones can make an official petition or procedure, based on the class's plan deliverable homeworks, to be graded by an external source. That is a normal procedure in most universities.
3-Would he possibly react the same way if only 1 student use the phone without making any noise?
R- That is hard to answer without knowing the person, but petty behavior does come from petty people, so yes, he could, or he might try to use that student as an example for everyone.
Having said that, you should consider that its basic respect and manners to not be messing with your phone when someone is speaking to you. More so, it's a class where you are supposed to be learning, so you'd be wasting the chance. If he did stated at the start of the course that he would not allow using phones, then the class is at fault.
However, to take into account is that there are many teacher, the older ones specially, that do not understand just how integrated is modern learning and technology. You could be taking notes on a tablet/notbook/smart-paperbook, check what he says and references on the phone, sending the photos of the whiteboard to the class's chat group, using the cloud to share the materials, etc . If that was the case, the whole group needs to speak to the teacher about it and get clear what is expected or allowed.