I think the answer lies in where you are. If you are in a state that requires NRTL listing (such as UL), then unless the enclosed breaker was listed with that specific contactor or relay in it, the labeling was violated and technically could not be acceptable to an inspector. If not, you are on your own and it is up to you to determine suitability.
From an engineering standpoint, breaker enclosures are sized based on wire bending space and air volume for the expected heat rise. If you add devices, you could be in trouble on either issue. If the new device is mounted in such a way as to not allow enough wire bending space, it could violate code with or without NRTL listing. If the devices added produce heat, you could be in trouble for the current rating of the breaker.
That said, it's also true that breaker manufacturers don't make a different size box for every trip rating of a breaker; usually just one per frame size. So for instance if you have a 40A breaker, the box is probably the same for everything up to 100A. In that case you may be able to accurately judge the wire bending space issue on your own if, as in the above example, the space originally provided in the box design was for much bigger wire than what you are using. But adding a lighting contactor may or may not negatively affect the breaker current rating and chances are you will not have enough information available to you, such as how much extra heat you can add in to the enclosure before de-rating becomes necessary.