We already do that. However not all plastics and be determined that way. Black plastic in particular often cannot be figured out (since the laser as absorbed) and so even if the plastic is easy to recycle it is often land filled.
There are open questions on if recycling plastic is worth bothering with at all, but that is a different debate.
Here's the machinery doing it.[1] It's just using RGB and IR cameras; they're not using lasers to vaporize samples and analyze the spectrum. That would be both overkill and a fire hazard.
Overview of modern waste handling.[2] Most of the separation is entirely mechanical, with screens, vibrators, rotating drums, and air blasts. But HDPE and PET plastics are separated using infrared sensing.
If you think about it, the oil just took a detour into being a water bottle or whatever for a little while on it's way to the power plant. I really can't imagine we'll be at 0 hydrocarbon electricity grid any decade soon and burning garbage (and instead of "recycling" plastic) seems to be a perfectly reasonable thing to do if you can do it cleanly in a power plant.
Thats good to know. On recycling or not, i dont think it will ever be a universal yes or no. But if the tech was there to reliably identify & pull out a processable stream that has concrete assessable value. Its probsbly a harder requirement on some sensing tech to do it with continuously on an industrialized stream of refuse.
There are open questions on if recycling plastic is worth bothering with at all, but that is a different debate.