I had the same question. Found the answer though! I have no idea where the Generic ones are kept, but...
Go to the ~\Library\Audio folder off your user folder (Library may be hidden so in finder hold Option key and while opening the "Go" menu in Finder).
In the Audio folder I didn't have a "MIDI Devices" folder so made one (MIDI Drivers was there, but not MIDI Devices).
Then made a folder in that called whatever I liked (in my case "TD-50" for Vdrums icons).
In there made a folder called "Images".
Pop some nice icons in that (need to get some nicer ones with transparent backgrounds) and voila! Doesn't matter what you name the actual icons seemingly. Now in MIDI studio I get "Generic" but also "TD-50" (the folder name) with that icon in, and now have another "RME" folder with "Images" subfolder there too with my UFX II icon in. Make as many as you like with Images subfolders for each or you could just call it "Greg's Bits" or whatever if you just want "Generic" and all your custom icons together in a single "Greg's Bits" icons section.
P.S. This is with Ventura 13.0.1