Yes, as long as you or your friend are in a public place where you are allowed to be, it is legal to record what the police are doing while they are on duty. (Penal Code section 148(g).)
However, it is important not to physically block the police or interfere with their investigation. Otherwise, they could accuse you of “resisting, delaying or obstructing peace officers…who are performing their official duties,” which is itself a crime. (Penal Code section 148(a)(1).)
Although a recording of the police acting improperly could be helpful evidence in a criminal case, please use your common sense and do not interfere with the officer’s investigation, put yourself in danger, or escalate the situation by taunting the police.