A megapixel is literally 1 million pixels. There's no concept of sub-pixels (more on that in a moment).
E.g. suppose a camera has a sensor resolution of 6000 x 4000 (to make the math easy) ... that works out to 24,000,000 pixels or, stated more simply, 24 megapixels.
The sensor on a camera is technically a monochrome device. It is covered with a matrix of photo-sites which accumulate voltage as photons (which carry energy) hit the photosites. In this way you can imagine that a digital sensor works a bit like an array of very tiny solar panels that convert light to energy. A camera isn't trying to power anything with the very tiny energy levels on each photo site ... it just wants to measure the energy accumulation to estimate how much light hit that particular spot. But it doesn't have a notion of color (yet).
Color Filter Arrays
To get color, the camera needs a Color Filter Array (CFA). You could use a monochrome sensor and take three photos ... one with a "red" filter, one with a "green" filter, and one with a "blue" filter. You now have a sample measuring the amount of red, green, and blue at each pixel. But since this requires three separate exposures (and that takes time) it doesn't work well for action photography.
The CFA of choice tends to be the Bayer Matrix. This is an array of very tiny color-filters in front of the sensor ... each tile on the array is only large enough to cover a single photosite. The tiles filter out red and blue light but allow green to pass through. The red and blue act similarly for their respective colors. In doing this, you have samples all all colors from just a single exposure.
See: Wikipedia - Bayer Matrix
This means the image collected is a monochrome image where each photosite only represents one particular color. If you read out the image and then assign the colors to each photosite (based on the bayer matrix) you'd get a mosaic image ... and that's no good. You need a way to demosaic the data to created blended color.
You could take the 2x2 cluster of pixels (traditionally two green, one red and one blue) and blend them (treating it like binning) to get a full color larger pixel. But this is not typically how the color camera works.
To create blended color (e.g. green and red make yellow) the camera performs a demosaicing algorithm. This algorithm (and there are many variations on it) takes each photo-site's color and intensity level ... and compares that to the adjacent photo-sites color & intensity levels. E.g. if you have a "green" photosite, it will have adjacent "red" and "blue" photosites. The algorithm might average the intensity value of all neighboring "red" photosites and also average the intensity value of all neighboring "blue" photosites and assign those as the values of red and blue component of the RGB "pixel". In this way, even though the image started out as single-channel monochrome data ... it ends up having three color-channel RGB data for every single pixel.
See: Wikipedia - Demosaicing
As an interesting experiment, you can shot a single image in 'RAW' format for your camera and check the file size. Now open that image and export it as a 16-bit TIFF image and you'll notice the file-size roughly triples. This is because RAW files only store the single channel data ... the color is derived by doing that "averaging of the neighboring colors" trick ... whereas a TIFF image actually stores three color channels for each pixel (the color is not derived.)
There is a concept called "binning". A "binned" image means that a cluster of physical photosites are combined and treated as if they are just one photosite. For example, 2x2 binning means that a cluster 2 photosites wide by 2 photosites tall are combined (for a total of 4 photosites) and treated as-if they are just one logical photosite.
While this does reduce resolution, it also reduces noise. When "binning", you do have sub-pixels involved ... but binning is not commonly used in traditional photography.