Is it once per wheel or crank revolution?
I’ve had similar before when it was crank revolutions and the extra force on the downstroke when going uphill (in the lowest gear) was enough to twist the wheel slightly and cause the rear mech cable to catch a spoke.
Took a while to figure it out and was on a road bike with relatively spindly wheels.
If you have a bike stand, could you simulate it by turning the cranks with the rear brake applying some load?
As a one stop test I’d give all the spokes a squeeze in twos, like back when we were young and a wheel mysteriously went wobbly – (nothing to do with the curb just cased at silly speeds 😉 )
edit. Another thought – what cassette and fixing method is it? If it is the four biggest cogs and they are on a std Shimano freehub, are they all in an assembled chunk as part of the cassette? If so, maybe a worn freehub or cassette, loose locking or similar that is allowing the cassette to clunk over as the force transfers.