Any car which wins an F1 race will justifiably viewed as 'a beauty' by the driver and owner, past and present. Some race winners might be described as 'inelegant', but none should be called ugly, thus no ugliest car.
For least elegance, I'd nominate the Talbot-Lago T26C, a winner in 1950 before the WDC season started... Solid and functional are two other appropriate adjectives. It was the right design for teams with little money who wanted to go up against the big boys. Fourth in the WDC for Louis Rosier was a well earned result. And it might have been that 4.5 litre engines were the right way had the WDC been run on F1 regs in 1952.
The BRM V16s are fascinating cars, but they aren't beauty contest contenders. The 1954 Vanwall Special was a bit contrary compared to the elegant cars which followed.
The March 701 might be described as solid and functional, although I'm sure a lot of work was required to keep them performing!
I think you have to go to the back of the grid in the 1980s and earlier to see cars which were plain ugly.
It is a long time since we have seen an elegant F1 car. Over the last 30 years, the rules have created cars which are too big, too heavy and reliant on aerodynamic clutter. A thought experiment for you: how much extra downforce do you need to generate if the mass/weight of a car increases by 30%? Serious answers in a separate thread.