What would happen to a flying aeroplane if suddenly there is hail in the sky?
For example, ice the size of a brick.
It depends on the severity of the hailstorm. In the event of encountering large hail pieces in the sky during cruise, a pilot will generally try to climb above the storm (of course with ATC permission) to prevent damage to the airframe. However, it is always better to stay out of the hailstorm in the first place and pilots will usually try to negotiate a course avoiding the hailstorm entirely using available weather data.
However, there are much more extreme cases such as this Boeing 727 which cracked its radome and its windshield after flying through a hailstorm at FL 350:
There were no pax onboard as it was a cargo flight for Capital Cargo International Airlines. After the severe damage to the airplane, the crew declared an emergency and safely landed at a diversion airport. Surprisingly, the airframe was repaired and put back in service after the incident.
There was a case where an easyJet Boeing flew through a hailstorm; the accident report is here, with a PDF download available, which lists some of the damage (which includes a cracked windscreen and damaged leading edges on wings and other surfaces).
There are photos showing the damage incurred, including the one below. Search for "easyJet hailstorm damage" to find more.
Frozen precipitation comes in many forms
Of these, hail and freezing rain are the biggest threats to aircraft and I'll focus on hail as that seems to be the topic of your question.
Hail, especially "brick sized" hail require very strong updrafts in severe thunderstorms to be able to form. We typically name hail sizes by round objects (not bricks) and on the high end we have baseball and softball sized hail. Hail bigger than that does exist, but it is uncommon.
These bigger hailstones are almost exclusively found very close to the updraft in supercell thunderstorms. To encounter these you really need to be flying somewhere you should not be. The turbulent conditions that will exist in the region of these hailstones is already a large threat to an airplane. Hailstones this big will severely dent the fuselage and likely shatter the windscreens. It would be a significant event. However these hailstones don't appear out of nowhere and you are extremely unlikely to see one if you aren't penetrating the worst part of severe storms.
Smaller hailstones can be further from the updraft of a storm and can be lofted some distance in the anvil (which extends downwind for many miles) in certain conditions. Here we are considering golf ball sized hail and smaller, which are still confined to being associated with thunderstorms. These hailstones will dent the aircraft skin and can possibly damage the radome and windscreens.
Most examples of hail damage you will find are aircraft that were on the ground as storms passed overhead.
You won't find "brick sized" hail randomly in the atmosphere, and you should not be getting close enough to experience these if you're flying safely around thunderstorms.
Here is an image courtesy of NOAA (public domain):
This image depicts composite radar (on the "ground" in the image) and a vertical radar cross section through the storm. The area labelled "Hail Core" is where the very large hail is going to be formed and is falling. The extreme radar echoes in this area are entirely due to the extremely reflective properties of the hail. This is an area of intense downdraft due to the falling hydrometeors. The area labelled "Weak echo region" is the base of the updraft. It has a weak radar presentation, because it is fast and violent enough that vapor is not condensing and raindrops not forming until well above the ground, and it is the raindrops and larger objects that radar can show us. Hail or no hail, this is not a region you want to be flying an airplane into.
Most of what I know has been mentioned, and excellent photographs!
When ice and water go into the air intakes of the jet engines, the ice gets rapidly chopped up into tiny pieces -- those spinning things you can see in the front of the the engine are turbines that slice and then compress the air going through, so the engine has more air to burn with, which generates more energy. It burns, and the exhaust comes out the back. At the back, the exhaust spins the whole turbine assembly, more air goes in, and so forth.
I've talked with SR-71 Blackbird pilots who tell me "essentially nothing" happens if a bucketload of ice and snow goes into those engines.
The things to actually watch out for are, first, as mentioned, impacts, and second, more subtly, is ice can form on the wings. The ice screws up the shape of the wing ("airfoil"), and that shape is what generates lift. Too much icing can make a plane fall out of the sky. The planes generally do have anti-icing measures -- mechanical, electrical heat -- and this is why the wings and cockpits are sprayed with de-icer before they back away from the gate when it's cold.
That helps some, but if you encounter wing icing, it's best to turn around and land, and call it a day!