How to test a used Mac before you buy it
There's plenty of life left in second-hand computers, especially if you happen to be shopping for an affordable student computer before the school year begins. With many districts implementing remote learning, the student computer is more important than ever, but how do you know if what you're buying is any good?

A typical 2017 Macbook Air for sale
But, if you see that you start the Mac and it asks for a firmware password, make sure the seller knows that password. It's possible that you may be able to boot to recovery and reset or disable it, or that you could ask Apple Support to disable it if you have a proof of purchase.
However, be aware this may be the point where it's easier to back out of the sale than deal with it.
iCloud lock is another security concern: if you're viewing a Mac for purchase, and on startup it says that it needs to be unlocked by iCloud, walk away. There are other Macs available for purchase.
Businesses and schools manage large numbers of devices using MDM, or mobile device management. An MDM supervisor can lock a device by placing it in lost mode.
In order to make such a machine worth purchasing, you need to have the seller log in, and remove the MDM profile from the machine. This is sometimes done by going to System Preferences > Profiles. Choose the Mobile Device Management profile, click the remove (-) button, and confirm the profile removal.
If the seller isn't able to do so, do not buy this Mac.
When we go to check out a computer, we have to do it relatively quickly, so that means coming prepared. We prepare a USB drive with a few utilities on it to diagnose a machine.
Are the corners dented? You're looking for signs of a drop that may have damaged internal components.
Look at the screen. Does the display glass appear evenly black across it, or does it look like the glass is de-laminating?
Look at the ports. Make sure they look undamaged. Note that it is relatively normal for a MagSafe port to have black marks inside it.

this is pretty normal
Also look at the power adapter for any signs of damage or discoloration. Sometimes the cable will break or burn at the MagSafe connector, or near the power brick.

this discoloration is not typical
Discoloration is a sign of an internally damaged cable, and one that may be necessary to be replaced in the future. This shouldn't stop you from considering purchasing the computer, but it is a cost to plan for.
For modern Macs made since 2013, hold down the D key when you power on the machine. Macs from 2011 that shipped with 10.7 Lion will launch Apple Hardware Test when started up while holding down D.
The only failure or warning you should be okay with is a failure to test the power supply charging capability. This is fine, if you're in a parking lot and are unable to plug in to the power adapter.

This is not good. Do not buy a computer with this result.
Apple does try and extend the life of the battery through power management and managing how quickly the battery recharges. Even so, the usable capacity of the battery will decrease over time.
Coconut Battery is an application that shows current battery health, including number of cycles, full charge capacity, and design capacity.

This is the author's battery. This is not good.
What you're usually looking for is how much full charge capacity remains, as it erodes as batteries age and go through charge-discharge cycles. A battery three years old may be capable of just 90% of the capacity it was designed for.
This isn't necessarily bad, but it can be a negotiating point for lowering the price.
Michael Simmons, the person behind apps such as DJay Pro and Fantastical, started out 20 years ago by writing a little application called PiXelCheck.
PiXelCheck isn't actively developed any longer, as it was last updated in 2012. But, it still runs on macOS Mojave, and we've confirmed that it will run on macOS Big Sur.

The utility will cycle through red, green, blue, white, and black screens to help you see dead or stuck pixels. It can also help show if there's backlight damage.
When pressure has been applied to the back of the display and it's pushed on the backlight layer of the inside of the screen, you may see brighter areas of the screen. It can also help you see 'stage light' problems, where you can see individual LEDs at the bottom of the screen, or brighter light at the bottom of the display than the top.
DriveDx has a 15-day trial, which is more than enough for testing a potential purchase, and will show health indicators of the SSD, including warnings of pre-failure.

There's a lot of information here, but look for anything not green.
Running these checks will help you make a good choice and hopefully provide you with a Mac that will serve for years to come.

A typical 2017 Macbook Air for sale
Before anything else, check a used Mac for iCloud lock, firmware passwords, and MDM
The ideal situation is one where the person selling the computer has wiped it and done a fresh install. When you start it up, you'll be presented with the steps to create a new account and can start running the test applications we named previously.But, if you see that you start the Mac and it asks for a firmware password, make sure the seller knows that password. It's possible that you may be able to boot to recovery and reset or disable it, or that you could ask Apple Support to disable it if you have a proof of purchase.
However, be aware this may be the point where it's easier to back out of the sale than deal with it.
iCloud lock is another security concern: if you're viewing a Mac for purchase, and on startup it says that it needs to be unlocked by iCloud, walk away. There are other Macs available for purchase.
Businesses and schools manage large numbers of devices using MDM, or mobile device management. An MDM supervisor can lock a device by placing it in lost mode.
In order to make such a machine worth purchasing, you need to have the seller log in, and remove the MDM profile from the machine. This is sometimes done by going to System Preferences > Profiles. Choose the Mobile Device Management profile, click the remove (-) button, and confirm the profile removal.
If the seller isn't able to do so, do not buy this Mac.
What diagnostics can you run, quickly
Let's say you find a listing on Craigslist, Facebook, Offerup, or Letgo, and you agree to meet a stranger, wearing masks. You only have a few minutes to test a computer without wearing out the patience of your seller. What can you do to make sure you're getting a good machine?When we go to check out a computer, we have to do it relatively quickly, so that means coming prepared. We prepare a USB drive with a few utilities on it to diagnose a machine.
Physical inspection
Look at the machine from every angle. Does it have dents or scratches on it? Does it appear to have been abused?Are the corners dented? You're looking for signs of a drop that may have damaged internal components.
Look at the screen. Does the display glass appear evenly black across it, or does it look like the glass is de-laminating?
Look at the ports. Make sure they look undamaged. Note that it is relatively normal for a MagSafe port to have black marks inside it.

this is pretty normal
Also look at the power adapter for any signs of damage or discoloration. Sometimes the cable will break or burn at the MagSafe connector, or near the power brick.

this discoloration is not typical
Discoloration is a sign of an internally damaged cable, and one that may be necessary to be replaced in the future. This shouldn't stop you from considering purchasing the computer, but it is a cost to plan for.
Apple Diagnostics
The first test you can do is run Apple Diagnostics. Long ago, this was called Apple Hardware Test, and it came on a DVD.For modern Macs made since 2013, hold down the D key when you power on the machine. Macs from 2011 that shipped with 10.7 Lion will launch Apple Hardware Test when started up while holding down D.
The only failure or warning you should be okay with is a failure to test the power supply charging capability. This is fine, if you're in a parking lot and are unable to plug in to the power adapter.

This is not good. Do not buy a computer with this result.
Test the battery!
Batteries do not last forever. They can perform worse over years of charge-discharge cycles and eventually become worn out.Apple does try and extend the life of the battery through power management and managing how quickly the battery recharges. Even so, the usable capacity of the battery will decrease over time.
Coconut Battery is an application that shows current battery health, including number of cycles, full charge capacity, and design capacity.

This is the author's battery. This is not good.
What you're usually looking for is how much full charge capacity remains, as it erodes as batteries age and go through charge-discharge cycles. A battery three years old may be capable of just 90% of the capacity it was designed for.
This isn't necessarily bad, but it can be a negotiating point for lowering the price.
How to check the LCD for discoloration or dead pixels
Decades ago, it was more common for LCD screens to occasionally have bad pixels. A pixel can be dead (always black, never lights up) or stuck (always on, never turns off).Michael Simmons, the person behind apps such as DJay Pro and Fantastical, started out 20 years ago by writing a little application called PiXelCheck.
PiXelCheck isn't actively developed any longer, as it was last updated in 2012. But, it still runs on macOS Mojave, and we've confirmed that it will run on macOS Big Sur.

The utility will cycle through red, green, blue, white, and black screens to help you see dead or stuck pixels. It can also help show if there's backlight damage.
When pressure has been applied to the back of the display and it's pushed on the backlight layer of the inside of the screen, you may see brighter areas of the screen. It can also help you see 'stage light' problems, where you can see individual LEDs at the bottom of the screen, or brighter light at the bottom of the display than the top.
Checking the SSD
SSDs are generally more reliable than hard drives, but they do have a finite life, based on how many rewrites of sectors that it has performed over its life. If you have time while meeting the patient stranger selling their computer, run DriveDx.DriveDx has a 15-day trial, which is more than enough for testing a potential purchase, and will show health indicators of the SSD, including warnings of pre-failure.

There's a lot of information here, but look for anything not green.
Conclusion
Thanks to Intel's slow processor march for the last eight years, you can still get an old Mac that will do what you need it to do. However, it's vital to be sure that it works, and works well before you plunk down cash.Running these checks will help you make a good choice and hopefully provide you with a Mac that will serve for years to come.

Comments
Was there any type of shipping insurance when you sent it to Apple?
Did they send you pictures of the damage?
Was there any way to speak to someone about how they received your iMac who can determine if this screen damage was from shipping, or go into more detail about what they found?
They sent me this information on Friday around 4pm and although I replied by email around 4:45 asking them for a picture of the damage I probably have to wait until Tuesday before I can expect a reply. I think this is a holiday weekend.
I edited my original post to apologize that I had the age of the iMac wrong. It was 6, not 3 years, so sorry, friend. But I'm also tempted to trade in my current 3 year old iMac in order to get the latest 2020 iMac. But now I'm scared if iMacs drop 80% in value during shipping.
If I take it back it might actually have a monitor problem (assuming that the shipping damaged it) then I've lost even the $150. I'm waiting for a description/photo of the damage before I decide what to do. I'm a little worried that this trade in system might be a scam by the contractor Apple is using, but I have no way to prove this and Apple wasn't interested in investigating when I called to chat with them. In the future I may just give my old computers to friends for free as a gift for being a friend.
The shipping box they sent me did not fit the profile of the iMac, and after trying various orientations settled on putting the iMac into the shipping box in the same orientation as the piece of cardboard with a picture of an iMac on it and forced the box closed.
Phobio claimed the 2014 iMac 4K arrived with screen damage in the lower left corner and reduced my estimated value from $540 to $130.
After some misgivings, I accepted the $130 simply because while I believe the shipping carton caused the damage, I also knew - having replaced an iMac 5K screen damaged in a slow motion accident for $567.05 in 2016 - that if I had them return the unit I'd have to replace the display before I could resell it, and the repair would cost more than the machine was worth.
If you're trading in a machine to Apple do it at a brick and mortar store - do NOT mail it in. If you're in desperate straits mail it in using the original shipping box and foam inserts if the shipping container they sent you doesn't fit properly.