This has already been done. It is a special rear hub with a strain guage between the cassette and the hub that measures the torque being applied to the rear wheel. The power is torque multiplied by rotational speed. There was a thread on this or the road forum recently titled "What is this" (the rear hub on a used bike he had bought).