You could turn on
gamerule doTileDrops whenever the player is near that block.
You could use
/loot to give yourself the block, but that only works before it is mined:
loot give @s mine <coordinates>
You could just simply
/give the block to the player, if you already know what it is.
/kill the drop whenever a different player is nearby.
/clear the item out of other players' inventories.
You could use spawn protection on a server and
/op yourself so that you can still place and mine inside the spawn protection area.
You could put other players into Adventure mode when they are nearby.