How to find the top level of the planetary boundary layer in WRF?
Well, the variable PBLH should tell you the PBL height. If you want the level that the PBL is, I suggest modifying the Registry.EM_COMMON file.
Perhaps I can refer you to WRF-Python to help you with your calculation. For example, wrf.interplevel might be the function to use to interpolate to the PBL height. If you interpolate to fractions of the PBL height, you could one of the integration methods to sum up the number of fractions of the PBL height and get the average concentration of $\ce{CO2}$ in the PBL (also, divide by the PBL height to actually get the average).