In several 4th edition books, I have seen traps and diseases, such as Deathsong (Book of Vile Darkness p33) or a magic crossbow turret. Is there a way for a character to learn how to create and use them? Or is it only for the Dungeon Master's use?
Unfortunately, "real" traps violate 4e's action economy.
However, for your specific example, the crossbow turret, it is possible. The Artificer has the power: Animate Arbalester which animates a crossbow she's holding so it can make attacks as a minor action.
For prepared traps in a stronghold or diseases, or any narrative device which is used outside of combat, use a skill challenge and narrate the consequences. If they're trying to defend their base or set up an ambush, encourage them.
For in combat things, allow the players to refluff their powers, such that to the narrative, they are doing these things, and to the mechanics they are performing their normal class powers.
I don't think there's a way you can do this with only the rules-as-written, but that's because I can't find the required elements, not because there's anything in the rules to prevent it.
That being said, I think you can add this into your game through creating new content without adding or modifying any rules. By that, I mean creating new items and martial practices and/or rituals.
By 'crossbow turret' I originally thought of something you would hand fire, which is more of a weapon, but maybe you meant something that fires on its own, which is more of a trap.
This is tough. I think rituals and/or martial practices are about the only way you can pull this off using just the mechanics available. These are extremely open-ended mechanics which can do just about whatever you want them to. The idea is to encapsulate longer, more complex actions that wouldn't make sense in combat. Combat actions are mostly represented by powers.
I would think creating a magic turret would be a ritual, rather than a martial practice. There is a martial practice, Forge Weapon, that lets you create a magical weapon, but it's just a base magic weapon +X, rather than one with the kind of special properties it would need to fire on its own.
Here's a possible ritual:
Conjure Crossbow Turret
Component Cost: 1,000 gp, plus a Crossbow as a focus
Market Price: 3,200 gp
Key Skill: Arcana
Time: 10 minutes
Duration: 1 hour
You magically animate a crossbow in an adjacent empty square. The crossbow will aim and fire magical bolts at your opponents. The crossbow is not consumed as part of the ritual, and no ammunition is needed.
On your turn, you may command the crossbow to fire as a minor action. It performs a ranged basic attack on the nearest enemy in range using your statistics as if you were firing it normally.
The maximum number of shots it can fire is determined by your Arcana roll. The crossbow falls to the ground in its space once it has fired its maximum number of shots, or when the duration ends, whichever occurs first.
Arcana Check Result Maximum Number of Shots 19 or lower 2 20-29 3 30-39 4 40+ 5
This is pretty powerful, as most rituals don't help you directly in combat, and certainly don't deal damage. You will have to be careful about how it is used, and might need to re-balance it at some point. The Arcana check table could be modified, you could require a Standard action to fire, or you could prevent them from applying a proficiency bonus, just to name a few possible tweaks.
Here's a possible way your characters could make a 'magic crossbow turret', by which I mean something along the lines of a light machine gun with a bipod. Create a new Superior Ranged Two-Handed Weapon:
Weapon: Crossbow Turret
Properties: Load Minor, Special
Crossbow Turret: This weapon cannot be fired unless it is set up, and cannot be moved unless it is taken down. Setting up and taking down are minor actions.
Allow your characters to create this weapon with the martial practice 'Master Artisan', or a magical version with the martial practice 'Forge Weapon'.
I don't have the Book of Vile Darkness, so I'm not sure what Deathsong does. The closest things I can think of which are not powers would be the Assassin (Executioner)'s poisons from Heroes of Shadow, or perhaps alchemical items which can be made by characters with the Alchemist feat from the Eberron Player's Guide. For either of these, you would simply need to create a new poison or a new alchemical item.