You can use either of the black wires for neutral and hot. You should connect the earth wire. The transformer is Class 2 but is not an impedance protected type, so it contains a thermal fuse or circuit breaker of some kind. The manufacturer’s data says
“Non-regenerative thermal overload protection” which is a bit ambiguous to me whether it’s a one-time fuse or whether it resets. I would assume it doesn’t reset, just dies relatively safely if overloaded.
I believe it’s intended to be mounted to the side of an electrical junction box which keeps the low voltage secondary separate from the mains.
Normal bell wiring is AWG 18, and for that gage you don’t need an output fuse, however 40VA is quite capable of causing a fire with the right amount of resistance so you may need a fuse in your particular application.
The important thing for safety is to ensure the earth lead is connected and that it is impossible to contact either mains lead. It would also be a good idea to ground the secondary or one side of your DC supply, so if the transformer fails it cannot cause a shock.
Strongly recommend having someone who is knowledgeable and present in person actually look at your setup before you attempt to power it. Shorting or overloading the transformer can cause it to fail. A fuse would be a good idea, but you will probably want a slo-blo type since the transformer will have to provide a surge of current to charge the capacitors and that can cause nuisance blowing. Also keep in mind your no-load DC voltage might well be more than 40V (due to xfmr regulation and peak of 24VAC RMS) so ensure your circuit can withstand that.