I've been experimenting a little, but I've mostly used Blender Internal, and only recently started using Cycles on a more regular basis, so this isn't perfect, but it may serve as a starting point. And to be clear: This isn't intended to create a nebula shape from a primitive object like a cube or a sphere, by just varying the density. Perhaps it can be built on to create something that does that, but probably not. Either way, with this setup, the shape has to be modeled.
This is an overview of the material:

The Color input of both the Scatter and the Absorption node groups are just that, color inputs. You can connect anything that outputs a color to them, ColorRamp, MixRGB, textures, or simply change the color directly, like with any node.
The Density texture and Anisotropy texture inputs of the Scatter node group and the Texture input of the Absorption node group control the density and anisotropy of the scattering and the density of the absorption respectively. You should connect the fac output of a texture, or anything that produces a value between 0 and 1, or you can set it directly.
The Maximum and Minimum inputs control the max and min density and anisotropy of the scattering and the max and min density of the absorption. The density of both go from 0 to the ridiculously high 10000, and the anisotropy of the scattering goes from -1 to 1. You can connect other nodes that produce such values, or you can set them directly.
The Curve shape inputs control how the densities and the anisotropy are distributed. A value of 1 gives a straight line from highest to lowest, a lower value gives more of higher density/anisotropy and a higher value gives more of lower density/anisotropy. They go from 0 to 1000.
Here's the "inside" of the Scattering node group:

And here's the "inside" of the Absorption node group:
In the setup I show here, I've used only one of each node group, and combined them with a mix shader with a factor of .5. As you can see, I've also used the same noise texture for everything. You may want to combine several of each node group, with different values, and, of course, different textures, and possibly something that gives a little randomness to the fac input of the mix shader(s), or perhaps try using (an) add shader(s) instead.
Here's a little something I put together with the exact setup shown here. It's certainly not a nebula, but like I said, this may be a starting point. It's not a complete solution.

Here's the .blend for this setup:
