The slots work differently, so you can't put ranged weapons in melee slots and vice versa. However, you can freely swap between melee and ranged weapons on your turn, so (leaving aside whether this is reasonable and balanced) if you want to attack melee with your main hand and with a hand crossbow with your bonus action you can. You'll just need to equip two handcrossbows in your ranged slots, but put the one you want your bonus action attacks to be with in the offhand slot.
If you then put your offhand ranged attack onto your custom toolbar, you can even map a hotkey to attack with it.