Both Sony WX500 and Panasonic ZS40 have 18.0 MP resolution sensors but Sony WX500's sensor is 1/2.3 (6.17 x 4.55 mm ) and Panasonic ZS40's sensor is 1/2.3-inch (6.17 x 4.55 mm ).
Since Panasonic ZS40's has a larger sensor area with the same resolution, this means that it also has a larger pixel area hence better light collecting capacity for a given aperture compared to Sony WX500.
Below you can see the WX500 and ZS40 sensor size comparison.
Sony WX500 and Panasonic ZS40 have the same sensor sizes so they will provide same level of control over the depth of field when used with same focal length and aperture.