If I have a Rail Travel Voucher, received due to delay repay, and the ticket office at my departing station is closed, and I obviously cannot use it the ticket machine, can I board the train and pay the guard if one is onboard / at my destination if there is not one?
It appears that you can, though I can't recall a train operating company explicitly considering this scenario. If we go to https://www.legislation.gov.uk/uksi/2018/366/regulation/6/made, it says
(4) In paragraph (2)(a), there are no facilities in operation for the sale of a travel ticket if—
(a)the passenger is not able to use any means of payment the passenger has available at the relevant time; and
(b)the passenger would usually be able to purchase a travel ticket at the station in question at the relevant time of day using one of those means of payment.
Given that you can normally use a RTV against the value of a ticket, I would think that 4(b) applies to you, and hence you should, in theory be fine. I'm not 100% sure though, and don't think this can be used in stations where RTVs can't be exchanged (this can be non-obvious, as you can't always exchange a RTV from Company X in a station operated by Company Y). I would recommend verifying this with the relevant TOC (train operating company) though.
Is this affected by driver-only operation / penalty fare?
No
Also, if the ticket office is also closed at my destination and there was no guard, am I free to just leave the station if there is no-one around to try to purchase the ticket from? If I had alternative means to pay at the machine (e.g., card).
I think so - I can't recall any explicit documentation around this - they don't seem to have considered the case you described.