I assume your gap is on the indoors side?
Regardless, if air is filtering through into the living space, there must be a gap outdoors ( external chimney) as well as indoors.
I recommend you check out the caulking along the chimney to the exterior siding as well as addressing the interior gap. Since this gap inside is directly adjacent to wood trim, I also have to assume that excessive heat is not a factor. Is the metal you are referring to an insert trim of some type? A pic would be a big help here.
If the assumption are right and the gap is 3/4 inch wide, I would use a caulking backer in the gap before using a good grade painter's or acrylic caulk as a topper. The caulking backer is a round foam solid tube that can be cut to length, inserted into the gap to seal it and hold the caulk. After the caulk has cured, it can be painted to match the trim. If for some reason you are concerned about high heat in this area, there is a fire rated caulk made especially for gaps in fire or common walls. Readily available at any box or hardware store from a number of manufactures.
Ok after reading your comments, and learning that the black vertical sides are slate, I would still do similar to above. Perhaps after injecting larger amounts of fire rated caulk as deep into void as possible, then use the solid, tube style caulking backer to fill the majority of the larger, deeper gaps, followed by using some paint-able silicon/acrylic mix caulk.
Before you apply the finish caulk, run a nice straight line of painter's tape up the front of the slate even with the edge of the wood trim. When you fill over the foam backer with the caulk, use a small putty knife to draw the caulk smooth and flat. Immediately remove the tape while caulk is fresh. This should result in a nice crisp straight line. Let the caulk cure for 24 hours. If there is some shrinking or cracks, no problem, simply repeat the process with new tape and another coat of caulk.
Alternately, you could also use a setting type drywall mud, such as durabond 30 or 45 to fill the deeper gaps etc. Then again use a second coat to create a smooth straight extension of the wood trim to the slate.
Either method will result in a neat, easy to paint fill that should stop your air infiltration problem and make the finish look nice.
I am proceeding on the assumption that these aren't visible areas, so looks do not matter.
I think you were right the first time, I'd use expanding foam for those jobs. I've used it in all sorts of cases like yours and it has done well. It isn't going to crush anything, even flexible dryer hose.
The alternative would be to cut pieces of drywall with the right diameter holes and to screw and/or glue them into place around this material. You'd need to move those wires around some if you have enough slack. Once the drywall is in place you'd just use caulk or silicone on the remaining small gaps.
Best Answer
The clearance for combustible materials to a properly built masonry chimney like you describe would be 0"; no clearance required.
I would use just about anything you want and worry more about getting your chimney inspected and cleaned on a regular basis.