The short answer is yes - this should work fine providing this is really a 24VDC 40A source designed to charge CC up to 40A to a peak voltage of 28V or so. So long as your batteries don't have shorted plate. If your batteries aren't hemorrhaging steam, but still are kinda crummy - we can assume they're heavily sulfated, so we can ignore them ;). Said bilge pump was designed to really run on 2 lead acid batteries in series, which could be 28V if they're freshly charged and in good shape so the slight charger mismatch is probably OK.
With chargers, the dumber the better when you're slightly re-purposing them, unless you're dealing with lithium. Last thing we'd want is for a smart charger to shoot itself in the head because the pump had a lot of brush noise or was a "15A load - but only when pushing high head pressure", and your pump load is actually low enough to make the charger think the battery is floated fully charged.
If your batteries are really discharged and capable of taking charge well - the charger voltage will droop quite a lot, but the pump may still run at a slower speed. Fast enough at a given pressure head and flow rate? You might have to calculate that, or just try it out.
Test this with an old rain barrel to buy yourself some piece of mind of course...
Now, about them batteries:
Based on your 24V and 6 batteries, sounds to me like you're running 2S3P - 2 series (24V) and 3 parallel? That'd be about 26V-30V depending on how good your batteries are. Those must be really heavy if each one is 12V/250AH? Over 100lbs each?