Loud disturbing motorcycles are awful but occasionally circle around certain roads after midnight up and down gratuitously if the objective is actually transportation. One would hope that there are laws on the books restricting the legality of such terribly loud machines in the first place, as a great portion of their appeal appears to be the disturbance caused to others, but if there are not, what is the status of riding them gratuitously at indecent hours? The public (neurological) health hazard is indeed great.
In the UK there is a maximum noise level of 89dB for all motorcycles, HGVs, PCVs.
If you often have a very loud motorbike near your home, you can leave a dB sound level meter near the road and film it just enough to get the level and the numberplate, and then the police will have a word and the guy will have to change it.
What happens on many motorbikes is that the noise absorbance tech in the exhaust is cheap and gums up and fails, else new exhausts are fitted.
I live near un up-hill road with loud engines, I became used to sleeping with 3M style foam ear buds, some people can become mentally sapped by noise and bad sleep from road noise.
It’s illegal to modify the exhaust system to make a vehicle noisier after it has been ‘type approved’ (checked it meets environmental and safety standards). The police can also take action if your vehicle’s silencer doesn’t work in the way it was designed or if you’re driving in a way that creates too much noise.
Many jurisdictions have enacted noise restrictions. For example Calgary, Alberta has a traffic bylaw that prohibits a person fom allowing their vehicle to make noise louder than 96 decibels, subject to a penalty of $270.00. See also CBC, "Noisy motorcycles, trucks target of bylaw review" (July 5, 2010).
In germany, motor vehicles need a permit to certify their technical fitness. Either the vehicle conforms to the manufacturer's specification, or modifications are inspected and recorded. Modifications to deliberately increase the noise would not be certified and illegal modifications may lead to the impounding of the vehicle. This happens with some frequency, often involving motor scooters and motorbikes.
In switzerland there's an article in the traffic law (Art 33 Verkehrsregelverordnung) that prohibits "continued, unnecessary driving trough towns". People can be fined for driving through towns, if they do that mostly for the sake of driving (and presenting themselves). Some towns have real problems with so called "car posers" that drive trough small streets near public gathering places with (often illegally) modified, expensive cars and howling engines. Of course, the law also applies to motorcycles.
Full article (german): https://www.swissrights.ch/gesetz/Artikel-33-VRV-2021-DE.php
So, as the OP is UK based, I thought it'd be helpful to answer some specifics:
There's two key offences:
Silencer/ exhaust system altered to increase noise – Reg. 54(2) The Road > Vehicles (Construction & Use) Regulations 1986;
Avoidance of excessive noise – Reg. 97 The Road Vehicles (Construction & Use) Regulations 1986
For cars, the (police measured) limit is 80 dB, and 89 dB for motorcycles...
...but, a crucial point is how these measurements are taken - the police measure the noise at 50% of max engine speed. Quite often, in both performance cars and motorcycles, there are electronically controlled valves to control the noise at lower engine speeds (allowing type approval).
As you can imagine, the noise difference between 7500 rpm and 15000 rpm can be significant.
For very obvious / egregious exhausts ("race use only", visibly modified or in some cases, removed completely), the first of the two offences is easier to prove.
germany In Germany, noise pollution is regulated in the immission protection laws which exist at the federal and state levels, and by the traffic regulations ("Straßenverkehrsordnung").
(1) Kraftfahrzeuge und ihre Anhänger, Schienen-, Luft- und Wasserfahrzeuge sowie Schwimmkörper und schwimmende Anlagen [...] müssen so betrieben werden, dass vermeidbare Emissionen verhindert und unvermeidbare Emissionen auf ein Mindestmaß beschränkt bleiben.
Avoidable emissions are to be avoided. You cannot just make your motorcycle loud because you like the noise.
The traffic regulations generally forbid "unnecessary noise and avoidable nuisance from exhaust fumes". The relevant paragraph is §30 (emphasis by me):
(1) Bei der Benutzung von Fahrzeugen sind unnötiger Lärm und vermeidbare Abgasbelästigungen verboten. Es ist insbesondere verboten, Fahrzeugmotoren unnötig laufen zu lassen und Fahrzeugtüren übermäßig laut zu schließen. Unnützes Hin- und Herfahren ist innerhalb geschlossener Ortschaften verboten, wenn Andere dadurch belästigt werden.
As in the environmental law, the general rule is to avoid avoidable noise and other pollution. More specifically, it is forbidden to run motors without a reason, rev it up where not necessary, slam doors etc.
But a very specific rule forbids riding back and forth within city limits without a reason if and when it annoys others.
This resembles the anti-cruising laws enacted by many communities in the U.S. and leads to similar social and legal discussions: In both countries, driving a car has connotations of freedom and adventure; excessive regulation interferes with the right to lead one's life as one sees fit. The German law only forbids cruising when it disturbs others though and has generally survived judicial scrutiny.