PWM amplifier 9v or 12v

Yes that will work but it is very wasteful of electric power. All the excess power gets turned into heat. You will need a heat sink attached to the regulator and that resistor needs to have a high enough rating to stand that current.