Panamanians appear to care about their appearance. Don't try to dress to 'fit in', just be yourself.
That being said, there is no need to wear a suit everywhere, either. Just dress conservatively and nice. For men, a clean pair of jeans and ironed collared shirt will do nicely for most excursions, you could dress more casually or more formally depending on the situation. Shorts are considered extremely casual wear suitable only for the beach, although this attitude has begun to change in some areas. Also, the longer Bermuda shorts made of nice fabrics are viewed as appropriate in many places.
However there is a dress code to follow to enter in all banks and governmental institution as well as many stores and supermarket. If you enter these establishments with inappropriate dress like wearing Bermuda or skirts above the knee, security will probably refuse access and ask you to leave.
Think nice, neat, and clean, and you will already be showing a great deal of respect for locals.
If you are making a side trip to Boquete, especially during the rainy season (April thru November) please dress in layers, bring a light rain jacket, and waterproof hiking boots.