Yes you can edit a JPEG and there's a lot you can do to improve a JPEG however you do not have all the same editing capabilities that are available working with raw files. That's not the case.
Load a JPEG into Adobe Camera Raw and increase the color temp value by 450 degrees K. You can't and it does matter.
You can't alter the input profile used to create a JPEG.
You can't alter the demosaicing algorithm used to create the JPEG.
You can't alter the lens distortion corrections used to create the JPEG.
You can't undo processes poorly applied when the JPEG was created.
You presented an impressive example of how access to a raw file can salvage a failed exposure. Consider that, working with most modern cameras, given access to a raw file and a good exposure for the camera JPEG I can always create from the raw file a final image with superior technical IQ than the JPEG created by the camera. There's a reason for this:
The software embedded in the camera processor that creates the camera JPEG is compromised. Over the years the engineers have worked very hard to minimize that compromise and to their credit they've done well, but ultimately they remain stuck between the classic rock and hard place. Every camera holds a gun to their head with the threat that at any time the user may press down the shutter release and hold it down. The expectation then is the camera will take a burst of photos very quickly. The camera's embedded JPEG processor has to keep up. To do that the engineers cut corners in the JPEG processing and it shows in that final image. They have no choice.
No camera manufacturer has yet attempted to offer a model camera advertised as; "get better quality SOOC JPEGs if you don't need to shoot X frames per second."
Here's an example. The OP has a Nikon D3500. I went to DPReview and the sample photos for the D3500 and selected an image that offered a low-light challenge:
Nikon D3500 sample gallery ISO was raised to 2800.
The camera JPEG processing is pretty awful. I processed the raw file using DXO PL-6. Here's a link to that processed image at full res:
d3500-raw.jpg
Below is a 100% crop comparing the two. I'm not using highly refined processing skills that took me years to learn. I'm just using better software. The D3500 isn't a poor camera it's typical. I can show you the same from my Z7. Could Nikon put better software into their cameras? Of course they can but that will come at a price they can't afford. The D3500 is rated at an impressive 5 frames per second continuous shooting. They'll have to give up.
View attachment 268078
Fuji has tried to address this problem recently and I'm not sure they're having much success. Here's a recent question that popped up at DPReview:
X-H2: Question about clarity setting: Fujifilm X System / SLR Talk Forum: Digital Photography Review about the new X-H2 slowing down when the JPEG clarity setting is used. Fuji added a couple JPEG features to their newest cameras and then put warning notices in the manual that using those features will slow the processor down. Users aren't seeing the notices in the manual they just think their cameras aren't working -- rock and a hard place.