Other than pokemon and megaman, and I guess some of the music things but that is a separate concept, is there anything that is not easier to just grab a save, load up in suitable PC emulator, get unlocks and go back from there?
https://nintendo.fandom.com/wiki/List_of_Nintendo_DS_games_with_GBA_connectivity
Anyway I have pondered it before, indeed it was for megaman, but as I own a great many flash carts then... I just use those. You don't even need the whole ROM as everything I tested (which was not everything but a lot) merely needed a suitable header of the ROM.
For the topic at hand though.
DS can read GBA slot (obviously) but it is more limited than the native GBA/GBA mode methods. This is good for you as it means anything reading the 0800000 through 09FFFFFF (though again only the header so it will be in the low 08000000 region) is likely to be what you want to look at -
http://problemkaputt.de/gbatek.htm#dscartridgegbaslot
Chances are the check will be a read (don't know if it will be DMA or a CPU memory read command), compare to known value and if good then proceed, if not matching then carry on with life (similar to how save hashes and antipiracy checks might work). You would then presumably change the branch if not equal or whatever it happens to be using for an instruction to always take the GBA cart present path. Alternatively if the serial matches thing sets a flag in memory then you could do that with a cheat.
In the case of megaman (which has multiple possibilities, as does Advance Wars depending upon the region -- there is 1, 2 and the Japanese bundle of 1 and 2 which does something for some regions) what I would hope would happen is each individual serial trips a flag in a IF this set IF this set IF this set flag... type manner but in normal operation only one is set as there can only be one GBA cart present. Many checks one after the other like that is considered bad programming form but for what is otherwise done the once per boot in a menu or something then it could be forgiven and thus I would expect it. Alternatively if it hard exits the loop after the first match you might have to get it to do a few other things but changing things here should be in place program flow options rather than having to crowbar new code in.
I don't know when the check will happen -- during boot/menu or when/shortly before loading the relevant bonus (see earlier link on how to get them) being the two main guesses. You should be able to set a breakpoint (it is a memory address/range after all), and you might even get lucky with a search of a disassembly (other than the DS browser and RAM based homebrew, and a proof of concept ROM hack I did once, nothing other than this should be touching the 08?????? range).
This will necessarily involve fiddling with assembly, which is a bit jumping in at the deep end but this is within reason, though I am not going to rule out being able to find a flag with an emulator (desmume having the GBA faking option, make a savestate some menus before the bonus, select suitable GBA ROM if you have not already, see what changes between launching into that screen and the next, load back savestate and lose the GBA game/replace with a non working one, repeat looking to see what differs between things, might have to repeat that a few times and also do things to eliminate background changes). You also have the other option of replicating whatever inventory item, bonus or the like is given via normal
cheats.