How can I build a circuit to drive a 12V solenoid from a 3V source, so up 3V to 12V by storing in capacitors, charge and discharge cycles?
Your solenoid might not be the best tool for the job (a 5V solenoid may work as-is* and a 12V solenoid would draw less current from your AA batteries), but if you absolutely want to hack something together to make the pair work, here is what you can do:


If you don't easily have access to other solenoids but you don't mind hacking this one: the force of a solenoid is proportional to the number of turns and the current going through them, therefore let's rewind it with the same number of turns and the same current, but at 3V. Count the number of turns of the coil as you unwind it (and make a note of the direction of the turns!), then measure the total length of wire. Measure its resistance. Divide the resistance by the length, and refer yourself to AWG gauge wire charts to get what gauge the wire is. Then, buy/find some wire which either has 8 times less resistance, or which has sqrt(8)=2.83 less copper radius. Re-wind the solenoid core with the same direction,and the same number of turns.
If you don't easily have access to toher solenoids and you don't want to bother (and you don't mind the additional volume), try buying one of these cheap step-up/"boost" modules which have in/out ranges including your 3V in, 24V out. THe current rating must be higher than that of your solenoid (if you're not sure, measure with an ampmeter). One major drawback of this method is that the module will draw about 10 times (8 times for power conservation, a bit more for non-ideal efficiency) more current than what the solenoid needs from your batteries. This will kill your batteries quickly, so you'll have to think about the battery life you need. This might in fact not work at all, since AA batteries have around 0.15Ohm internal resistance, so depending on the current required the input voltage may sag below the minimum input voltage of your module (or might decrease its efficiency, eventually having the same effect).


Those are just ideas, time to explore!

*: Look for the minimum pull-in and release voltages in the datasheet of your solenoid, these are the values you need to guarantee