The test you need in this case is called a PCR or diagnostic test. It shows whether or not you have the coronavirus infection right now, and is different from the antibody test (which can be used to show whether or not you have previously had an infection).
Anyone with symptoms should be able to order a PCR test for free if they have symptoms via their regional healthcare service. But this won't provide you with a travel certificate (reseintyg), and you may not be able to take these tests if you don't currently have symptoms.
So for a test in order to travel abroad, you may need to use a private clinic. The Public Health Agency has published a list of clinics offering tests which can provide you with a travel certificate, including information for booking options if you don't have a Swedish personal identity number. See the full list here.
Check the requirements for the country you're travelling to. It's common that the test needs to have been carried out recently, for example within the last 24-72 hours, and that the travel certificate may need to be in English.
Some countries require incoming travellers to be tested for the coronavirus on arrival, which means that bringing proof of a recent test result from Sweden won't be enough. For example, Iceland requires travellers to either quarantine for two weeks or take a test at your own expense; bringing a negative test result from Sweden isn't sufficient to bypass this.
And if you're unable to provide the test results in a country that requires it, you may be refused entry or required to take a test (probably at your own expense) and to quarantine for a set period of time.
For example, travellers to Austria without a test result must take the test within 48 hours of arrival (they're available at the airport), and quarantine until they receive a negative result.
Make sure that you've checked the current requirements from the country you're travelling to (and any countries you need to travel through in order to get to your final destination) and be aware that these could change at short notice as the coronavirus situation develops. Information about entry requirements for travellers from Sweden can be found from the embassies on Sweden Abroad.