Updated:

1. Run a command on drop

scoreboard objectives add drop minecraft.custom:minecraft.drop
# Repeat, Always Active
execute as @a[scores={drop=1..}] run tellraw @s {"text":"You dropped an item","color":"gray"}
# Chain, Always Active
scoreboard players reset @a[scores={drop=1..}] drop

2. An offering altar

execute positioned 0 64 0 as @e[type=item,distance=..1.5] if items entity @s contents minecraft:diamond run tag @s add offered
execute as @e[type=item,tag=offered] at @s run give @p minecraft:emerald 5
kill @e[type=item,tag=offered]

Run them in a repeat and two chain blocks. A diamond thrown near (0, 64, 0) is swapped for five emeralds. contents is the slot of a dropped item (1.20.5+). See area detection.

3. Items that come back

/give @s minecraft:compass[custom_name="Keepsake",custom_data={bound:1b}]
execute as @e[type=item] if items entity @s contents *[custom_data~{bound:1b}] at @s run tp @s @p
execute as @e[type=item] if items entity @s contents *[custom_data~{bound:1b}] run data modify entity @s PickupDelay set value 0s

Put the last two in repeat and chain blocks. A dropped bound item jumps to the nearest player and can be picked up at once.

4. Clear dropped items

/kill @e[type=item]

See the kill command.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.