How can I programmatically set individual voxels?

I want to do some volumetric rendering of a volume I create by setting individual points, not from loading a file and not from using primitives like the cylinder, cone, sphere, etc. How can I do this?

Also, is it bad if there’s millions of voxels and the vast majority of them are the insides of solid shapes? Should I clear them out somehow and store only the surfaces? How should I do that?