Refer to the datasheet, namely the section on the Waveform Generation Modes (WGM) available for timer2. To get an arbitrary frequency, you must be able to adjust the TOP and prescaler to get the desired frequency, then set the output compare value to get the desired duty cycle. The only mode of the 8-bit asynchronous timer2 that allows you to set the TOP requires you to use OCR2A, which takes out one of the two PWM channels. You are much better off using one of the 4 16-bit timers (1,3,4,5), which, in addition to being much better timers for any purposes where an asynchronous timer is not required (which is basically never in arduino-land), have a WGM where you can specify the TOP via the ICRn register, leaving both PWM pins available.
In any event, you can't get it from any 8-bit timer with a 16MHz system clock and prescaler of 32 anyway - this is basic math - 16,000,000/32/800 is 625. In a dual-ramp WGM from an 8-bit timer, you can only count to 512, even if you can set TOP. One could of course use a larger prescale, but then you lose resolution, and that still doesn't address Timer2's lack of an appropriate WGM...
And no matter what, if you're making arbitrary frequency PWM, forget about analogWrite! analogWrite is only for 8-bit PWM, and with prescaling only available in powers of 2, you only have so many options for the frequency.
The right course of action is to use one of the 16-bit timers in WGM where you set TOP with the ICR register, iirc it's WGM 14 on the mega's 16-bit timers on the AVRs. Hell, then you wouldn't even need to prescale it!
Just set it to WGM, the appropriate pins as output, put timer fast PWM with TOP set by the timer's IRC register, prescaler of 1... 16000000/800=20000, so set ICRn to 19999 (0 is one cycle) - (it's a 16-bit register), set the COMnx bits to 2.
Then, to set the duty cycle, you can just write something like
void setDutyCycle(unsigned int duty) {
OCRnx = duty;
}
That argument would be relative to the TOP value, of course, so instead of calling analogWrite(pin,127) to get 50% duty cycle, assuming 800Hz desired output frequency (ie, TOP=19999), you'd call setDutyCycle(9999)...
In register names above per Atmel's convention, n is the timer number, x is channel letter, ex, ICR1, OCR1A, etc.
On the atmega2560 used in the mega, you even get 3 output channels per timer instead of 2 like most AVRs!
The classic AVR timers are pretty straightforward. I was staring at the megaavr (eg, atmega4809 as used on nano every, or the megaavr 0-series and 1-series tinies) all night - they're quite a bit more complicated - but damned cool... Overall, though, the classic avrs often give you more timers, more output pins, etc, particularly as you move up the product line... they're also way more expensive though (with the exception of, like, the 328pb, which is cheaper than a 328p, despite having a second uart/spi/i2c interface, 4 extra I/O pins and 3 of those juicy 16-bit timers instead of just 1 like the 328p had... but I digress...