It's very doable with a "full" (but fairly simple) mod. If there is an existing mod out there which can already do this using a config or scripts, I don't know about it.
The way to do it is to subscribe to PlayerInteractEvent.RightClickBlock, then filter for your wanted block type(s) and have it create and drop the items in-world (or give them directly to the player).
Can also destroy the block from there if you want.
Btw, was this a mod request, or just a request for info so *you* can make the mod?