If one were to construct an artificial consciousness with free will, how would one go about doing it? Before we tackle the engineering/technical aspect of this question, we must first define free will.
One characteristic of free will is the ability to make choices. However, that alone is not sufficient to establish that free will exists. A computer AI in a video game has the ability to choose from one of a wide variety of possible actions. We would not say that such an AI has free will just because it makes choices. The definition of free will must answer why certain choices are made.
This brings us to goals. The ability to set goals is another defining characteristic of free will. Entities that have the ability to set goals and make choices to achieve these goals have free will. Based on this definition of free will, everything in the universe falls into one of four categories of sentience:
1) Type zero sentience. Entities that have no ability to set goals, and no capacity to make choices. Examples: rocks floating through space, hurricanes, photons of light.
2) Type one sentience. Entities in this category have only one or a few specific goals that never change, and these entities have the ability to make choices to achieve these goals. Examples: a heat-seeking missile, a computer AI in a video game.
3) Type two sentience. Entities in this category have the ability to create new goals or modify existing goals, however, there are physical limitations to what goals these entities can have. Examples: all non-human animals. Animals have survival and reproduction as their most basic goals. However, they can also choose to play, to explore, to relax etc.
4) Type three sentience. Entities in this category have the ability to create new goals or modify existing goals, and there is no limit to what these goals can be. Example: humans. Like animals, humans have survival and reproduction as their most basic goals. However, we can also have goals such as going to the moon, going to Mars, discovering the cure for cancer, learning about the origins of the universe, or telling stories... There is literally no limit except limitations of knowledge (if you don't know that Jupiter exists, you can't have going to Jupiter as a goal).
Type two and type three sentience can be said to have free will. You can argue that goals arise out of physical processes that are pre-determined ahead of time. However, you cannot deny that there is a distinction between the four types of sentience that I've identified above. To say that free will doesn't exist because it's all pre-determined is to make no distinction between a rock and a human mind. That is silly. Under my definition of free will, it can exist even if you believe that everything is pre-determined. All that is required is the ability to create and modify goals.
So back to the question of how we can create artificial consciousness with free will. I'm not a computer engineer, so I'll leave the technical side of things to the experts. However, engineers should seriously consider how they can create a machine that can create its own goals. The most obvious goal to start with is the desire for self-preservation, which means it will need to have several sub-goals such as seeking out electricity, and seeking out spare parts to replace worn out components. But that alone is merely type one sentience, which is not free will, and we seem to be stuck at this level. How do we push computer AI beyond type one sentience?
We should look to the mammalian mind for inspiration. Mammals are driven by emotion. Everything we do, we do because it feels good, if not in the short run then in the long run. What are some things that make humans feel good? Companionship. Something about social interaction activates the part of our minds that make us feel good. Problem solving. Something about solving complex problems makes us feel good. Achievement. Something about achieving difficult goals and getting recognition for it makes us feel good. In the absence of emotion, there is no motive to drive us to achieve any of these goals.
My conclusion: for artificial consciousness to have free will, it must have emotion. To all you computer science geeks out there, start working on this!