Yes, you are allowed to deduct reasonable and necessary expenses for your rental. If you didn't have solar panels you would have to pay utility bills, so they are a utility expense.
On the flip side, if you get paid for excess electricity generation, you will need to declare the income (or reduce your utility expense).