Similar to other distances races, putting the time and effort into preparing yourself to run a 6k is a good idea. Especially if you're new to the sport of running, you could really risk a serious injury if you show up on race day without any sort of running foundation or base built. But a 6k distance is also an excellent race to start with if this is your first competitive running experience, even if you don't intend to run to compete, because it's a manageable race distance.
First off, it is more likely that you will find races measuring 5k or 10k in distance. A 6k is not a common distances, so if you have your heart set on the 6k distance specifically, make sure there's actually a local 6k race that you can sign up for. A 6k measures just over 3.7 miles, so it might take you some time to get into shape. Follow a training plan that gets you into 5k shape (click here for some training plan ideas!) and then add on one or two more weeks in which you add a bit more distance.
In general, you will want to take it bit by bit. Don't try and run the entire 6k distance the first day you lace up your shoes! Set a goal to run just a half mile without stopping, not worrying about your pace. Speed will come as you build up your endurance. And don't run multiple days in a row at first. You'll risk an overuse injury. Instead, aim to run three or four days a week, at half mile distances each time. Then, at the onset of the next week, add another half mile to that distance so you work your way up to running a mile, 3-4 days a week. Continue adding half mile distance intervals each week until you can run four miles without stopping. (If you start your first week at half a mile, then this'll take you about eight weeks, so make sure you give yourself at least 8 weeks out from the 6k race to train.)