Can the hidden layer prior to the ouput layer have less hidden units than the output layer?
A layer with bigger number of nodes than previous one is something very common. Some examples are:

strategies encoder-decoder (autoencoders) where the encoder typically  has layers with a decreasing number of nodes (until the compressed/encoded data) and the decoder has layers increasing in number of nodes.

bidirectional recurrent networks where in the forward direction number nodes decreases and in the backward increases.

generators, that from a random vector generates, by example, a full image.


As general rule: decrease number of nodes forces the net to filter/resume/abstract/summarize the internal signal information (discarding useless information or noise) while increase number of nodes means apply current information to generate an answer value for a specific question/target.
Allow me a strongly simplified example: assume you want a system that, from a photo of an animal, answers the questions: number of legs? has beak ? flies ? . Net inputs are images of birds and dogs.
The net architecture can have layers of decreasing size until a single node that will decide &quot;is bird or dog ?&quot;. From this single item of information (the only one need to answer all the questions) the output layer will have 3 nodes, each one answering one of the specific target questions: number or legs ? 4 if dog, 2 if bird, etc .